Skip to main content
3 of 4
deleted 8 characters in body
Oliver Ni
  • 10.7k
  • 4
  • 42
  • 110

Encode the alphabet cipher

Given a string that contains 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.) 8 5 12 12 15
  2. Pad each number to two characters with 0s. 08 05 12 12 15
  3. Join. 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