First, let's review the Simple Substitution Cipher.

To encode a string in the Simple Substitution Cipher, replace each letter in your string with another letter.

A letter may not be used to replace more than one existing letter.

For example, if I was encoding the text Hello world, my name is Oliver! I like code golf! with the key zyxwvutsrqponmlkjihgfedcba (a -> z, b -> y, etc.) then the encoded text would be Svool dliow, nb mznv rh Lorevi! R orpv xlwv tlou!.

Your task

Your task is to encode the simple substitution cipher. Given a string of decoded text and a key, output the encoded text.

Remember, this is , so the code with the fewest number of bytes wins.

  • 4
    \$\begingroup\$ Given a string of encoded text and a key, output the encoded text. There should be a decoded in there shouldn't it? \$\endgroup\$
    – Emigna
    Commented Nov 2, 2016 at 16:43
  • \$\begingroup\$ reopened this as per our policy of closing older answers as dupes of older questions. \$\endgroup\$
    – Maltysen
    Commented Nov 2, 2016 at 16:59
  • 2
    \$\begingroup\$ A little more details would be nice. In your example, you encode uppercase letters that do not appear in your key, yet no such thing is mentioned in the spec. \$\endgroup\$
    – Dennis
    Commented Nov 2, 2016 at 17:01
  • 1
    \$\begingroup\$ This is essentially "Implement UNIX tr", and just parameterises an existing tr question. \$\endgroup\$ Commented Nov 2, 2016 at 17:12


Browse other questions tagged or ask your own question.