Skip to main content
added a shorter version
Source Link
Arnauld
  • 197.8k
  • 20
  • 179
  • 650

JavaScript (Node.js), 60 bytes

Expects (permutation_string)(string).

p=>s=>(B=Buffer)(s).map(c=>(B(p)[q=c&32,c-q-65]||c)&95|q)+''

Try it online!


JavaScript (ES6), 42 bytes

Assuming using lists of ASCII codes is acceptable:

p=>s=>s.map(c=>(p[q=c&32,c-q-65]||c)&95|q)

Try it online!

JavaScript (Node.js), 60 bytes

Expects (permutation_string)(string).

p=>s=>(B=Buffer)(s).map(c=>(B(p)[q=c&32,c-q-65]||c)&95|q)+''

Try it online!

JavaScript (Node.js), 60 bytes

Expects (permutation_string)(string).

p=>s=>(B=Buffer)(s).map(c=>(B(p)[q=c&32,c-q-65]||c)&95|q)+''

Try it online!


JavaScript (ES6), 42 bytes

Assuming using lists of ASCII codes is acceptable:

p=>s=>s.map(c=>(p[q=c&32,c-q-65]||c)&95|q)

Try it online!

Source Link
Arnauld
  • 197.8k
  • 20
  • 179
  • 650

JavaScript (Node.js), 60 bytes

Expects (permutation_string)(string).

p=>s=>(B=Buffer)(s).map(c=>(B(p)[q=c&32,c-q-65]||c)&95|q)+''

Try it online!