Skip to content

Instantly share code, notes, and snippets.

@e-jigsaw
Created January 2, 2012 15:32
Show Gist options
  • Save e-jigsaw/1551119 to your computer and use it in GitHub Desktop.
Save e-jigsaw/1551119 to your computer and use it in GitHub Desktop.
New year card coding!
var str = ["HOGE", "SOME", "TEXT", "IN", "HERE", "PIYO"];
for(var t in str) {
var c = t + 2;
t = parseInt(t);
console.log(t+1);
for(var i in str[t]) {
var right = str[t].charCodeAt(i) + (t+1);
var left = str[t].charCodeAt(i) - (t+1);
if(right > 90) right -= 26;
if(left < 65) left += 26;
if(c <= (t+1)) console.log(String.fromCharCode(right + 32));
else {
console.log(String.fromCharCode(left));
c = 0;
}
c++;
}
console.log("------------------------");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment