Skip to main content
2 of 7
added 2555 characters in body
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#05AB1E, 68 bytes

.•5Ç¿ÆΓ•2ô.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ι놽òι•4ô«UI'b¡εg>}s£εXsk}h2ôJHçJ

Input is in lowercase.

Try it online.

For some reason 'b¡εg>}s£ε.•5Ç¿ÆΓ•2ô.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ι놽òι•4ô«sk}h2ôJHçJ doesn't work. There seems to be some kind of weird bug/behavior with the second mapping. I also can't get a test suite for all test cases up and running..

Also, can definitely be golfed with something smarter than the huge compressed strings. Will take another look later on.

Explanation:

.•5Ç¿ÆΓ•      # Compressed string "bibabobu"
        2ô    # Split in parts of 2
              #  → ["bi","ba","bo","bu"]
.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ι놽òι•
              # Compressed string "bidibidabidobidubadibadabadobadubodibodabodobodu"
        4ô    # Split in parts of 4
              #  → ["bidi","bida","bido","bidu","badi","bada","bado","badu","bodi","boda","bodo","bodu"]
«U            # Merge both together, and save it in variable `X` (work-around)
              #  → ["bi","ba","bo","bu","bidi","bida","bido","bidu","badi","bada","bado","badu","bodi","boda","bodo","bodu"]
  I'b¡        # Take the input and split on 'b'
              #  i.e. "bidibadibidobidabidobodibidobodibidoboduboba"
              #   → ["idi","adi","ido","ida","ido","odi","ido","odi","ido","odu","o","a"]
      εg>}    # Map each to its length+1
              #  i.e. ["idi","adi","ido","ida","ido","odi","ido","odi","ido","odu","o","a"]
              #   → [4,4,4,4,4,4,4,4,4,4,2,2]
s£            # Split the input-string into parts of that size
              #  i.e. "bidibadibidobidabidobodibidobodibidoboduboba" and [4,4,4,4,4,4,4,4,4,4,2,2]
              #   → ["bidi","badi","bido","bida","bido","bodi","bido","bodi","bido","bodu","bo","ba"]
  ε   }       # Map each to:
   Xsk        #  The index in variable `X`
              #   i.e. ["bidi","badi","bido","bida","bido","bodi","bido","bodi","bido","bodu","bo","ba"]
              #    → [4,8,6,5,6,12,6,12,6,15,2,1]
h             # Convert everything to hexadecimal
              #  i.e. [4,8,6,5,6,12,6,12,6,15,2,1]
              #   → ["4","8","6","5","6","C","6","C","6","F","2","1"]
 2ôJ          # Split it in parts of 2 and join them together
              #  i.e. ["4","8","6","5","6","C","6","C","6","F","2","1"]
              #   → ["48","65","6C","6C","6F","21"]
    H         # Convert that from hexadecimal to an integer
              #  i.e. ["48","65","6C","6C","6F","21"] → [72,101,108,108,111,33]
     ç        # And take its ASCII value
              #  i.e. [72,101,108,108,111,33] → ["H","e","l","l","o","!"]
      J       # Then join everything together (and output implicitly)
              #  i.e. ["H","e","l","l","o","!"] → "Hello!"
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384