Skip to content

Instantly share code, notes, and snippets.

@Galaxtone
Forked from LyricLy/bruteforce.py
Last active May 16, 2018 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Galaxtone/2affc932077c4f399719d6e90bd28f88 to your computer and use it in GitHub Desktop.
Save Galaxtone/2affc932077c4f399719d6e90bd28f88 to your computer and use it in GitHub Desktop.
Brute force Kolmogorov complexity for The Insane Esolang
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