Skip to content

Instantly share code, notes, and snippets.

@supphawit
Last active December 2, 2021 10:36
Show Gist options
  • Save supphawit/fdf19b6f5bbe31d87bc92e64582251a6 to your computer and use it in GitHub Desktop.
Save supphawit/fdf19b6f5bbe31d87bc92e64582251a6 to your computer and use it in GitHub Desktop.
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