1
\$\begingroup\$

This question already has an answer here:

Review

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.

\$\endgroup\$

marked as duplicate by Peter Taylor code-golf Nov 2 '16 at 17:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 Nov 2 '16 at 16:43
  • \$\begingroup\$ reopened this as per our policy of closing older answers as dupes of older questions. \$\endgroup\$ – Maltysen Nov 2 '16 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 Nov 2 '16 at 17:01
  • 1
    \$\begingroup\$ This is essentially "Implement UNIX tr", and just parameterises an existing tr question. \$\endgroup\$ – Peter Taylor Nov 2 '16 at 17:12

Browse other questions tagged or ask your own question.