compressionesoteric-languages05ab1e

How to separate compressed words from each other in 05AB1E?


05AB1E is a golfing language and it has a large dictionary of words which can be implemented to the code using a single-character command or multi-character command.

Is there any way to separate the compressed words in case a string contains multiple implementation commands?

This is my 05AB1E code: ”ŽØ¢©„‚…”

Explanation:

”     # begin string, separate words with space, title-case

ŽØ    # compressed word "happy"

¢©    # compressed word "birthday"

„     # compressed word "to"

‚…    #compressed word "you"

”     # end string

I am trying to print "Happy Birthday To You", but instead it prints Happy Birthday County…, because the compiler confuses „‚ to a compressed word county, leaving alone. It should read first , then ‚…, and this is where separation would be useful.

You can find all 05AB1E commands in here.


Solution

  • To index into the word list, you always need two parts, a "high" one for the hundreds, and a "low" one for the ones (just like you did with Ž for 12 and Ø for 79 to get "happy" at index 1279, and with ¢ for 26 and © for 33 to get "birthday" at index 2633).

    Therefore, to get the word "to" at index 3 (which you would read as 003), just prepend your for 3 with for 0.

    Note that for the word "you" at index 14, you likewise need for 0 and î for 14, not for 1 and for 4 which would instead get you "people" at index 104.

    Also note that the trailing marker for string literals ( in this case) is optional if there's no other command to access the string, so you might want to just drop it.

    ”ŽØ¢©€„€î
    
    Happy Birthday To You
    

    Try it online!