-
-
Save supphawit/fdf19b6f5bbe31d87bc92e64582251a6 to your computer and use it in GitHub Desktop.
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 test = (p, seed) => { | |
let a = 'abcdefghijklmnopqrstuvwxyz' | |
let r = '' | |
let i = 0 | |
for (const c of seed) { | |
if (p.length === i) { | |
i = 0 | |
} | |
if (c !== ' ') { | |
// increase | |
// r += a[a.indexOf(c) + parseInt(p[i]) >= 26 ? Math.abs((a.indexOf(c) + parseInt(p[i])) - 26) : a.indexOf(c) + parseInt(p[i])] | |
// decrease | |
r += a[a.indexOf(c) - parseInt(p[i]) < 0 ? Math.abs((a.indexOf(c) - parseInt(p[i])) + 26) : a.indexOf(c) - parseInt(p[i])] | |
} else { | |
r += ' ' | |
} | |
i++ | |
} | |
return r | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment