-
-
Save Galaxtone/2affc932077c4f399719d6e90bd28f88 to your computer and use it in GitHub Desktop.
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
var gen = (function() { | |
var alphabet = "26LHG15DZ83OCTNS9 KIFPVUJEB7W0MAQ4XYR"; | |
function mod(x,y) { | |
if (x < 0) return mod(y-x,y); | |
if (x >= y) return mod(x-y,y); | |
return x; | |
} | |
function Ĭ(value) { | |
return mod((value + 4) * 5, 256); | |
} | |
function đ(value) { | |
return mod(mod(value - 2, 17) * 3, 256); | |
} | |
return function gen(text) { | |
var code = ""; | |
var value = 45; | |
for (var i = 0; i < text.length; i++) { | |
var index = alphabet.indexOf(text[i].toUpperCase()); | |
if (index < 0) continue; | |
var loop = []; | |
var inst = 0; | |
while (mod(value, 37) != index) { | |
value = Ĭ(value); | |
code += "Ĭ"; | |
if (loop.includes(value)) { | |
loop = []; | |
value = đ(value); | |
code += "đ"; | |
} | |
loop.push(value); | |
} | |
code += "ǿ"; | |
} | |
return code; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment