Created
May 15, 2018 09:53
Brute force Kolmogorov complexity for The Insane Esolang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bound = lambda m: m if 0 <= m <= 255 else (bound(m + 256) if m < 0 else bound(m - 256)) | |
alphabet = "26LHG15DZ83OCTNS9 KIFPVUJEB7W0MAQ4XYR" | |
value = 45 | |
code = "" | |
value = bound(value) | |
def do_i(code, value): | |
value += 4 | |
value *= 5 | |
value = bound(value) | |
code += "Ĭ" | |
return code, value | |
def do_d(code, value): | |
value -= 2 | |
value %= 17 | |
value *= 3 | |
value = bound(value) | |
code += "đ" | |
return code, value | |
def do_u(code, value): | |
value //= 4 | |
value += 59 | |
value = bound(value) | |
code += "ù" | |
return code, value | |
for char in input(): | |
idx = alphabet.index(char) | |
loop = [] | |
e = 0 | |
while value % 37 != idx: | |
if e == 1: | |
code, value = do_d(code, value) | |
elif e == 0: | |
code, value = do_i(code, value) | |
else: | |
code, value = do_u(code, value) | |
if value in loop: | |
loop = [] | |
e = (e + 1) % 3 | |
loop.append(value) | |
code += "ǿ" | |
print(code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment