Skip to content

Instantly share code, notes, and snippets.

@jfktrey
Created January 24, 2014 19:48
Show Gist options
  • Save jfktrey/8604718 to your computer and use it in GitHub Desktop.
Save jfktrey/8604718 to your computer and use it in GitHub Desktop.
Obfuscated base transform
h = (n = prompt("in base-3: ")).length - 1;
b = +(o = []);
l = (m = Math).log;
for(i = h; i + 1; i--) b += m.pow(3,i) * n[h - i];
for(p = (b + "").length * l(10) / l(7) | 0; p+1;)
o.push(b / m.pow(7, p--) | 0),
b -= o[o.length - 1] * m.pow(7, p+1);
alert("in base-7: " + o.join("").substr(!o[0]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment