Skip to main content
4 of 4
All the solutions are already assuming the string contains *only* lowercase letters, but this should be made unambiguous.

Encode the alphabet cipher

Given a string that contains only lowercase letters, encode that string with the alphabet cipher.

To encode with the alphabet cipher (I will be using the example hello):

  1. First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15
  2. Pad each number to two characters with 0s. Example: 08 05 12 12 15
  3. Join. Example: 0805121215

Test cases

helloworld -> 08051212152315181204 codegolf -> 0315040507151206 alphabetcipher -> 0112160801020520030916080518 johncena -> 1015081403051401 

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

Oliver Ni
  • 10.7k
  • 4
  • 42
  • 110