This is the decryption challenge. The encryption challenge can be found here.


The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer to this challenge!

Equivalent of a Character

Now, firstly you would need to know how to find the "equivalent" of each character.

If the character is a consonant, this is the way of finding it's equivalent:

1) List all the consonants in alphabetical order
    b c d f g h j k l m n p q r s t v w x y z
2) Get the position of the consonant you are finding the equivalent of.
3) The equivalent is the consonant at that position when starting from the end.

eg: 'h' and 't' are equivalents of each other because 'h', 't' are in the 6th position from start and end respectively.

The same procedure is followed to find the equivalent of vowels/digits. You list all the vowels or the digits (starting from 0) in order and find the equivalent.

Given below is the list of the equivalents of all the characters:

b <-> z
c <-> y
d <-> x
f <-> w
g <-> v
h <-> t
j <-> s
k <-> r
l <-> q
m <-> p
n <-> n

a <-> u
e <-> o
i <-> i

0 <-> 9
1 <-> 8
2 <-> 7
3 <-> 6
4 <-> 5

Rules of Decrypting

  1. You start with two empty strings, let's call them s1 and s2. We will be moving from left to right of the input string. At the beginning, we would be considering the first empty string, i.e, s1. We will be switching between the two strings whenever we encounter a vowel.

  2. We take the equivalent of the current character of the input string, or a blank space if it is a blank space. Let's call this character c. c is now appended to the right of s1 (if we are considering s1 currently) or to the left of s2 (if we are considering s2 currently).

  3. If that character was a vowel, switch to the other string now (s1 <-> s2).

  4. Repeat step 2 (and 3 for vowels) for every character in the input string.

  5. Concatenate s1 and s2 and the result is the decrypted string.

Now let me decrypt a string for you.

String = "htioj ixej uy "
Initially, s1 = s2 = ""
Current: s1
Moving left to right
"h" -> "t" (s1 = "t")
"t" -> "h" (s1 = "th") 
"i" -> "i" (s1 = "thi")
Vowel encountered. Switching to s2 now.
"o" -> "e" (s2 = "e")
Vowel encountered. Switching to s1 now.
"j" -> "s" (s1 = "this")
" " -> " " (s1 = "this ")
"i" -> "i" (s1 = "this i")
Vowel encountered. Switching to s2 now.
"x" -> "d" (s2 = "de") [Note that when dealing with s2, we append to the left]
"e" -> "o" (s2 = "ode")
Vowel encountered. Switching to s1 now.
"j" -> "s" (s1 = "this is"
" " -> " " (s1 = "this is ")
"u" -> "a" (s1 = "this is a")
Vowel encountered. Switching to s2 now.
"y" -> "c" (s2 = "code")
" " -> " " (s2 = " code")
Now, append s1 and s2 to get:
"this is a code"

Output -> "this is a code"


"wqcjmc" -> "flyspy"
"toek" -> "hero"
"toyike" -> "heroic"
"uo" -> "ae"
"uoz" -> "abe"
"htoo jmuy" -> "the space"
"uh68v8x " -> "a d1g13t"
"fo78i d" -> "we xi12"
"htioj ixej uy " -> "this is a code"
"jea ceeac hnx8x vni kokhj jiuth xoqqc xohmcky" -> "so you really decrypted this string d1dnt you"

You may also choose to use uppercase alphabets instead of lowercase.


This is , so the shortest code wins!


8 Answers 8


Jelly, 29 bytes


A full program which prints the decoded text.

Try it online!


ØḄ,ØẹØDṭ,U$F€yµe€ØẹŻœṗµ;ṚU$m2 - Main Link: list, S
ØḄ                            - consonant characters
   Øẹ                         - vowel characters
  ,                           - pair
     ØD                       - digit characters
       ṭ                      - tack -> ["bcd...","aeiou","012..."]
          $                   - last two links as a monad:
         U                    -   upend -> ["...dcb","uoiea","...210"]
        ,                     -   pair -> [["bcd...","aeiou","012..."],["...dcb","uoiea","...210"]]
           F€                 - flatten each -> ["bcd...aeiou012...","...dcbuoiea...210"]
             y                - translate S using that map
              µ               - new monadic chain (i.e. f(A=that))
                 Øẹ           - vowel characters
               e€             - (for c in A) exists in (vowels)?
                   Ż          - prepend a zero
                    œṗ        - partition (A) before truthy elements (of that)
                      µ       - new monadic chain (i.e. f(that))
                                  ...e.g.: f(["thi","e","s i","do","s a","c "])
                          $   - last two links as a monad:
                        Ṛ     -   reverse    ["c ","s a","do","s i","e","thi"]
                         U    -   upend      [" c","a s","od","i s","e","iht"]
                       ;      - concatenate  ["thi","e","s i","do","s a","c "," c","a s","od","i s","e","iht"]
                           m2 - mod-2 slice  ["thi",    "s i",     "s a",    ," c",      "od",      "e"      ]
                              - implicit, smashing print -> this is a code

JavaScript (ES6),  112 110  109 bytes

Expects an array of characters.

s=>s.map(c=>(C="bzcydxfwgvhtjskrlqmpnn  aueoii",c=C[j=C.search(c)^1]||9-c,+s?b=c+b:a+=c,s^=j>23),a=b='')&&a+b

Try it online!


We look for the index of each character c in the following lookup string:

 0         1         2
"bzcydxfwgvhtjskrlqmpnn  aueoii"

If the character is not found, it must be a digit which is replaced with 9-c. Otherwise, we get the position of the counterpart character by inverting the least significant bit of the index.

For instance: j1213s

The new character is either appended to a or prepended to b.

We switch between a and b whenever the index is greater than 23 -- i.e. c is a vowel.


Python, 226, 160 146 bytes

Try it Online

I am fairly new to python and wanted to try this challenge. I know a lot of this can be improved using lambda or simplified code. I am showing my code so I can get feedback.

Thanks to @Arnauld for helping me learn new ways to code. Now at 160 bytes

More inputs and refinements. Now at 146.

def k(y):
x='aueoiibzcydxfwgvhtjskrlqmpnn0918273645  '
for i in y:n=x.find(i);b[s]+=x[n+1-2*(n%2)];s^=n<6

Old Code:

def k(y):
 x='aueoiibzcydxfwgvhtjskrlqmpnn0918273645  '
 def a(t):
  m=n+1 if n%2==0 else n-1;t+=x[m];return t
 for i in y:
  if s:
  if n<=5:s=not s

k('htoo jmuy')
k('uh68v8x ')
k('fo78i d')
k('htioj ixej uy ')
k('jea ceeac hnx8x vni kokhj jiuth xoqqc xohmcky')

Tested all the sample items and got the correct response.

"wqcjmc" -> "flyspy"
"toek" -> "hero"
"toyike" -> "heroic"
"uo" -> "ae"
"uoz" -> "abe"
"htoo jmuy" -> "the space"
"uh68v8x " -> "a d1g13t"
"fo78i d" -> "we xi12"
"htioj ixej uy " -> "this is a code"
"jea ceeac hnx8x vni kokhj jiuth xoqqc xohmcky" -> "so you really decrypted this string d1dnt you"
  • 1
    \$\begingroup\$ Nice 1st answer, please post a tio.run link to your code that doesn't contain any comments. \$\endgroup\$ Commented Aug 22, 2020 at 10:01
  • 1
    \$\begingroup\$ Welcome to the site. You might find Tips for golfing in Python useful. \$\endgroup\$
    – Dingus
    Commented Aug 22, 2020 at 12:05
  • 1
    \$\begingroup\$ Some tips: Use n<6 instead of n<=5. Use s=1-s instead of s=not s. You can replace def a(t):... with a=lambda t:t+x[n+1-2*(n%2)] (197 bytes). \$\endgroup\$
    – Arnauld
    Commented Aug 22, 2020 at 13:28
  • 1
    \$\begingroup\$ Going a step further, you can save many bytes by using a list of strings instead of b and c (160 bytes) \$\endgroup\$
    – Arnauld
    Commented Aug 22, 2020 at 13:36
  • 1
    \$\begingroup\$ This is why I love this community. Learning things everyday. Thank You for the tips @Arnauld and Dingus \$\endgroup\$
    – Joe Ferndz
    Commented Aug 22, 2020 at 15:02

Retina 0.8.2, 89 83 80 71 bytes



Try it online! Link includes test cases. This turned out to be easier than encoding, as demonstrated by the fact that I was able to code it in Retina 0.8.2 rather than requiring Retina 1. Explanation:


Split the input on substrings ending on vowels. An extra split is forced at the end of the string so that there are at least two lines.


Join alternate lines together, so that the first line is the concatenation of all the odd lines and the second line is the concatenation of all the even lines.


Matching only the characters on the last (second) line...


.. reverse the matches, thus reversing the second line only.


Join the two lines together and decode the letters. The Ro causes the string to transliterate to its reverse. The middle consonant n and vowel i map to themselves so don't need to be listed. The maps to the special _ thus deleting it. The first and last 10 consonants and the first and last two vowels then surround the digits. (The o is normally special so it has to be quoted here.)


R, 190 bytes

function(i,`/`=strsplit){a=el(" 01234aeibcdfghjklmnpqrstvwxyziou98765 "/"")
for(l in a[el(i/"")]){if(T)j=c(j,l)else k=c(l,k)

Try it online!

Note to self: learn a new, non-R, language to golf text-based challenges...


`/`=strsplit){                  # use infix '/' as alias to strsplit function
 a=el(" 01234aeibcdfghjklmnpqrstvwxyziou98765 "/"")
                                # a=vector of characters with equivalents at reverse index
 names(a)=rev(a)                # name characters by equivalent
 j=k=""                         # initialize j,k as empty strings
 for(l in a[el(i/"")]){         # for each input letter (split using /), find its equivalent l
  if(T)j=c(j,l)else k=c(l,k)    #  if T=1 (initial value) append l to j, otherwise put it at start of k
  if(grepl(l,"aeiou"))T=!T}     #  if it was a vowel, T=not T
 cat(j,k,sep="")}               # finally, output j,k

C (gcc), 144 143 140 bytes

-1 -3 bytes thanks to ceilingcat


Try it online!


05AB1E, 27 26 bytes


I/O as a list of characters.

Try it online or verify all test cases (with the I/O joined to pretty-print).


žM             # Push the vowels "aeiou"
  Iå           # Check for each character in the input-list if it's in the vowel string
               #  i.e. ["h","t","i","o","j"," ","i","x","e","j"," ","u","y"," "]
               #   → [0,0,1,1,0,0,0,1,0]
    0š         # Prepend a leading 0
               #  → [0,0,0,1,1,0,0,0,1,0]
      Å¡       # Split the (implicit) input-string on the truthy values
               #  → [["h","t","i"],["o"],["j"," ","i"],["x","e"],["j"," ","u"],["y"," "]]
        ι      # Uninterleave the list of lists
               #  → [[["h","t","i"],["j"," ","i"],["j"," ","u"]],[["o"],["x","e"],["y"," "]]]
         €S    # Convert each inner list of lists to a flattened list of characters
               #  → [["h","t","i","j"," ","i","j"," ","u"],["o","x","e","y"," "]]
           `   # Push both lists of characters separated to the stack
               #  → ["h","t","i","j"," ","i","j"," ","u"] and ["o","x","e","y"," "]
            R  # Reverse the second string
               #  → ["h","t","i","j"," ","i","j"," ","u"] and [" ","y","e","x","o"]
             « # Merge the two lists together
               #  → ["h","t","i","j"," ","i","j"," ","u"," ","y","e","x","o"]
žN             # Push the consonants "bcdfghjklmnpqrstvwxyz"
  Â            # Bifurcate it; short for Duplicate & Reverse copy
   ‡           # Transliterate the "bcdfghjklmnpqrstvwxyz" to "zyxwvtsrqpnmlkjhgfdcb"
               #  → ["t","h","i","s"," ","i","s"," ","u"," ","c","e","d","o"]
žM‡           # Do the same for the vowels "aeiou"
               #  → ["t","h","i","s"," ","i","s"," ","a"," ","c","o","d","e"]
žh‡           # And the digits "0123456789"
               #  → ["t","h","i","s"," ","i","s"," ","a"," ","c","o","d","e"]
               # (after which the result is output implicitly)

Perl 5 -F, 110 bytes


Try it online!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.