Last active
December 18, 2017 10:27
-
-
Save LAITONEN/6084933893d5a08c34d557fa0abe7bc8 to your computer and use it in GitHub Desktop.
Python Challenge 2 done with Javascript http://www.pythonchallenge.com/pc/def/map.html
This file contains hidden or 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
const riddle = 'g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr... amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyrq... ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb.... lmu ynnjw ml rfc spj.'; | |
const alphabet = 'abcdefghijklmnopqrstuvwxyz'; | |
const orderNumber = alphabet.split('').map((v, i) => { | |
return { newIndex: i+2, letter: v }; | |
}) | |
const result = riddle.split('').map(v => { | |
if (/[a-z]/.test(v)) { | |
return orderNumber[orderNumber[alphabet.indexOf(v)].newIndex].letter; | |
} | |
else if (v !== ' ') return v; | |
return ' '; | |
}).join('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment