Created
November 3, 2016 05:22
-
-
Save hirokidaichi/5a324e07b064527ccd19012ce17e5ffb to your computer and use it in GitHub Desktop.
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 O = "i have a pen i have an apple apple pen".split(""); | |
var E = "i oari a fib i oari ab affwi affwi-fib".split(""); | |
var code = function(s) { | |
return s.charCodeAt(0) - "a".charCodeAt(0); | |
}; | |
var decode = function(n) { | |
return String.fromCharCode(n + "a".charCodeAt(0)); | |
} | |
for (var i = 0, l = O.length; i < l; i++) { | |
var o = O[i]; | |
var e = E[i]; | |
if (o == " ") { | |
continue; | |
} | |
var oCode = code(o); | |
var eCode = code(e); | |
console.log(o, e, oCode, eCode, e == decode((oCode * 2) % 25)); | |
} | |
/* | |
i i 8 8 false | |
h o 7 14 true | |
a a 0 0 true | |
v r 21 17 true | |
e i 4 8 true | |
a a 0 0 true | |
p f 15 5 true | |
e i 4 8 true | |
n b 13 1 true | |
i i 8 8 false | |
h o 7 14 true | |
a a 0 0 true | |
v r 21 17 true | |
e i 4 8 true | |
a a 0 0 true | |
n b 13 1 true | |
a a 0 0 true | |
p f 15 5 true | |
p f 15 5 true | |
l w 11 22 true | |
e i 4 8 true | |
a a 0 0 true | |
p f 15 5 true | |
p f 15 5 true | |
l w 11 22 true | |
e i 4 8 true | |
p f 15 5 true | |
e i 4 8 true | |
n b 13 1 true | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What the..