Skip to content

Instantly share code, notes, and snippets.

@masylum
Created April 12, 2011 13:50
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 masylum/915521 to your computer and use it in GitHub Desktop.
Save masylum/915521 to your computer and use it in GitHub Desktop.
var A = ['01001100', '01101000', '01010000', '01010011', '01001001', '01000011', '01101000', '01101001', '01110110', '01101001', '01110000', '01101100', '01100010', '01000111', '01101000', '01111010', '01100101', '01111001', '01101101', '01100001'],
B = ['10010001', '01011110', '01100101', '10011010', '10000010', '11110000', '11010000', '00101101', '11111000', '11010110', '11100000', '00011011', '01101110', '11110000', '01101100', '01101010', '11001010', '11001011', '01101110', '01110010'],
rotate = function (shift, str) {
return str.slice(1) + shift;
},
isRotated = function (a, b) {
return [].some.call(b, function (el) {
return b = rotate(el, b), a === b;
});
};
console.log(A.reduce(function (prev, el, i) {
return isRotated(el, B[i])
? prev + String.fromCharCode(parseInt(el, 2))
: prev;
}, ''));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment