Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
*/
@CEOmurky

This comment has been minimized.

Copy link

CEOmurky commented Jan 15, 2019

What the..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.