Solution: Adventure
Answer: PASIPHAE

Written by Jon Schneider

Players are dropped into a text-based adventure game that takes place in a series of interconnected rooms. Each room contains a giant letter on the floor, a blackboard, a button, and occasionally a monkey which gives you some information about the game.

Navigating through the dungeon reveals that there are 26 rooms, arranged in (roughly) the same layout as the 26 letter keys on a keyboard. Sorting the 26 letters on the floors of each room by the letter on the corresponding key on a QWERTY keyboard reveals the message: “TYPESAMETHINGBOTHKEYBOARDS”.

What are the two keyboards? The first is the keyboard you (the player) are typing on when entering commands into the game. The second is the dungeon in the text adventure itself. Here typing a key means pressing the button in the associated room. Your goal is to type a sequence of commands on the first keyboard (the real keyboard) which results in the same sequence of letters being typed on the second keyboard (the game keyboard). Further confirming this to the solver is the fact that typing a key on the game keyboard that causes its letters typed so far to stop being a substring of the letters typed so far on the real keyboard causes the game to immediately reset. For simplicity, all spaces and line breaks are ignored, and case does not matter (the relevant keys do not even appear on the game keyboard).

The puzzle now reduces to constructing this sequence of commands (which the reader may recognize as being a type of quine). Some thought makes it clear that it is impossible to construct such a sequence just by navigating around the dungeon and pressing buttons: typing each key on the game keyboard requires at least one (and often many more, to navigate to the correct key) character on the real keyboard, so it will be impossible to cause the two strings to match in this way. To succeed we need to use the remaining mechanics present in the text adventure, the key mechanic (haha) being our ability to write commands to a blackboard and later execute them with a single command by reading from that blackboard.

For completeness, we list below all the available commands in the text adventure. (Multiple commands can be entered in a single line, but some commands like ‘T’ and ‘A’ consume the rest of the content on the line.) Players learn what these commands do through the advice provided by the monkeys in-game.

  • ‘E’, ‘W’, ‘NE’, ‘NW’, ‘SE’, ‘SW’: move in the corresponding hexagonal direction (assuming it is possible to move in that direction).
  • ‘P’: press the button in the current room.
  • ‘T’: write the remainder of the line to the blackboard in the current room (overwriting whatever previously existed on the blackboard).
  • ‘R’: read from the blackboard in the current room, executing its contents as if you entered them as a single line in the text adventure.
  • ‘A’: append the remainder of the line to the blackboard in the current room.
  • ‘D’: erase the last character of whatever text is written on the blackboard in the current room.
  • ‘I’: execute the remainder of the line only if the blackboard in this room is empty.
  • ‘J’: execute the remainder of the line only if the blackboard in this room is not empty.
  • ‘L’: display a log of the characters you have typed on the real keyboard.
  • ‘K’: display a log of the characters you have typed on the game keyboard.
  • ‘V’: toggle ‘verbose’ mode (whether the actions you take while reading a blackboard are described or not).
  • ‘Q’: restart the game.

There are several possible ways to construct a successful sequence of commands. Many of these ways only use a small subset of the above commands (some of the commands, like ‘L’, ‘K’, and ‘V’ are primarily intended for debugging purposes). Here we describe one way to come up with a successful sequence that only uses the ‘A’, ‘P’, ‘R’, ‘E’, ‘W’, ‘N’, and ‘S’ keys.

Let’s call the log of characters we’ve typed on the real keyboard the real log, and the log of characters we’ve typed on the game keyboard the game log. No matter what we do, at the start the real log will grow faster than the game log. Our goal is to reach a state where we can somehow deal with whatever string of letters has accumulated in the real log.

One way to achieve this is as follows. We will designate one of the blackboards as the “master blackboard”; this will be the blackboard we read from at the very end of the solution. Initially the master blackboard will be empty. For every key we might want to press (one of ‘APREWNS’ in this solution), we assign a “key blackboard” (for simplicity, this can just be the blackboard located at that key’s room). Each key’s blackboard contains a sequence of commands that when read will 1. type that key (on the game keyboard) and 2. append a sequence of commands to the master blackboard that, when read, will press whatever sequence of keys were entered on the game keyboard to read from the key blackboard. Our strategy then proceeds in three phases:

  • Phase 1: Set up all the key blackboards by navigating to them and writing the appropriate sequence of commands on them. Navigate back to the master blackboard when finished.
  • Phase 2: Now the real log is full of a bunch of commands, and the game log is empty. Let s be the state of the real log at the beginning of this phase. For each character c in s, in order, navigate to room c and read the blackboard in this room. This will enter c in the game log, return to the master blackboard room, and append some stuff to the master blackboard.
  • Phase 3: Finally, read from the master blackboard. This will append to the game log any commands that were written to the real log during phase 2, thus completing the quine.

For example, let’s say we’ve set up all the key blackboards, the master blackboard is at room H, and we are at room H. Assume our real log starts with the character “N” (and we haven’t typed any keys on the game keyboard yet, so the game log is empty). The first button we must press is in the N room. To do that, we enter the command ‘SE R’, which moves southeast to the N room and reads from the board in the N room. Reading from this board types N on the game keyboard, navigates back to the master blackboard, and appends a sequence of commands to the master blackboard which, when read, will type ‘SER’ on the game keyboard. We proceed like this until we have dealt with the initial backlog of commands in the real log, and then we read from the master keyboard to deal with whatever we have added to the real log while dealing with the initial backlog of commands.

(Technically, this solution does not deal with the very final ‘R’ command needed in phase 3 to read from the master blackboard. This can be dealt with by setting up an “auxiliary” blackboard that simply reads from the master blackboard, and then finally types ‘R’ on the game keyboard). A detailed description of this strategy along with a sample sequence of commands is provided at the end of this document.

There are many other solution strategies. A strategy similar to the above can be implemented using only the commands ‘TPREWNS’. A substantially different strategy is to use the commands ‘I’ or ‘J’ to create a “god string” of commands that performs radically different actions depending on how line breaks are added to it, and have the input be copies of the god string with different line breaks; in this way, the real log can be made very regular, making it much easier to type the same keys on the game keyboard.

Completing this task successfully reveals to the player that the answer to this puzzle is PASIPHAE.


We start in room H. We will call this room our “home”. We will only ever use the keys ‘n’, ‘e’, ‘w’, ‘s’, ‘a’, ‘p’, and ‘r’. We will write on the blackboards in rooms G, H, N, E, W, S, A, P, and R.

The blackboard in room G is the “master blackboard”. We will not directly write anything to the “master blackboard” (we will only write on it when reading commands from other blackboards).

The blackboards in rooms N, E, W, S, A, P, and R are “key” blackboards. Each of these blackboards has an “address”: a fixed sequence of commands that navigates from home to that key, reads it, and then returns home. We will write a sequence of commands on each key blackboard that presses the button in its room, then navigates to room G and appends a sequence of commands to the master blackboard that types the key’s address on the game keyboard.

For example, the address of room P is “ne e e e r e”, since “ne e e e” navigates from room H to room P, “r” reads the key blackboard in P (which navigates the player to room G), and “e” moves the player from room G back to home. So the sequence of commands we write on the blackboard in room P is:

p               # type p on the game keyboard
sw w w w w      # move to room G
a               # write a sequence of commands to the master blackboard that types “ne e e e r e” on the game keyboard (and then returns to the master blackboard)
    se e p
    w w w nw nw p
    p
    p
    p
    e p
    w p
    se e e

Here is what we’ll write on each key blackboard, displayed in the form:

<key> (<address>):
	<blackboard nicely formatted>
<blackboard concatenated on one line>

N (sere):
    p               # type n on the game keyboard
    nw w            # move to G
    a               # append commands that type address
        w w w p
        ne p
        e p
        w p
        se e e
pnwwawwwpnepepwpseee

E (nwwwwre):
    p               # type e on the game keyboard
    se e e          # move to G
    a               # append commands that type address
        se e p
        w w w w nw nw p
        p
        p
        p
        e e p
        w p
        se e e
pseeeaseepwwwwnwnwppppeepwpseee

W (nwwwwwre):
    p               # type w on the game keyboard
    se e e e        # move to G
    a               # append commands that type address
        se e p
        w w w w nw nw p
        p
        p
        p
        p
        e e p
        w p
        se e e
pseeeeaseepwwwwnwnwpppppeepwpseee

S (wwwwre):
    p               # type s on the game keyboard
    e e e           # move to G
    a               # append commands that type address
        w w w nw p
        p
        p
        p
        e e p
        w p
        se e e
peeeawwwnwppppeepwpseee

A (wwwwwre):
    p               # type a on the game keyboard
    e e e e         # move to G
    a               # append commands that type address
        w w w nw p
        p
        p
        p
        p
        e e p
        w p
        se e e
peeeeawwwnwpppppeepwpseee

P (neeeere):
    p               # type p on the game keyboard
    sw w w w w      # move to G
    a               # append commands that type address
        se e p
        w w w nw nw p
        p
        p
        p
        e p
        w p
        se e e
pswwwwwaseepwwwnwnwppppepwpseee

R (nwwwre):
    p               # type r on the game keyboard
    se e            # move to G
    a               # append commands that type address
        se e p
        w w w w nw nw p
        p
        p
        e e p
        w p
        se e e
pseeaseepwwwwnwnwpppeepwpseee

The blackboard in room H will be the final blackboard we read. It navigates to room G, reads from the master blackboard, and then finally navigates to room R and presses it to take care of the final ‘r’ command.

H:
    w r         # append all the things
    w nw p      # press R
wrwnwp

In phase 1 we must navigate to all of these keys and write to their blackboards as described above. We need to visit rooms H, N, E, W, S, A, P, and R. We will take the path H -> N -> P -> R -> E -> W -> A -> S -> H.

# start at H
awrwnwp                                     # write to H
se                                          # go to N
apnwwawwwpnepepwpseee                       # write to N
enenee                                      # go to P
apswwwwwaseepwwwnwnwppppepwpseee            # write to P
wwwwww                                      # go to R
apseeaseepwwwwnwnwpppeepwpseee              # write to R
w                                           # go to E
apseeeaseepwwwwnwnwppppeepwpseee            # write to E
w                                           # go to W
apseeeeaseepwwwwnwnwpppppeepwpseee          # write to W
sw                                          # go to A
apeeeeawwwnwpppppeepwpseee                  # write to A
e                                           # go to S
apeeeawwwnwppppeepwpseee                    # write to S
eeee                                        # go to H

The real log after phase 1 is:

awrwnwpseapnwwawwwpnepepwpseeeeneneeapswwwwwaseepwwwnwnwppppepwpseeewwwwwwapseeaseepwwwwnwnwpppeepwpseeewapseeeaseepwwwwnwnwppppeepwpseeewapseeeeaseepwwwwnwnwpppppeepwpseeeswapeeeeawwwnwpppppeepwpseeeeapeeeawwwnwppppeepwpseeeeeee

For each character in this real log, we need to enter the address of that character. This address navigates to the corresponding key blackboard, reads from that key blackboard, and then navigates back to home. Recall that the addresses are

N: sere
E: nwwwwre
W: nwwwwwre
S: wwwwre
A: wwwwwre
P: neeeere
R: nwwwre

We can generate a sequence of commands by replacing each character in the above log with its address (one good way to do this is via judicious use of find-and-replace). This results in the following command for phase 2:

wwwwwrenwwwwwrenwwwrenwwwwwreserenwwwwwreneeeerewwwwrenwwwwrewwwwwreneeeereserenwwwwwrenwwwwwrewwwwwrenwwwwwrenwwwwwrenwwwwwreneeeereserenwwwwreneeeerenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwreserenwwwwreserenwwwwrenwwwwrewwwwwreneeeerewwwwrenwwwwwrenwwwwwrenwwwwwrenwwwwwrenwwwwwrewwwwwrewwwwrenwwwwrenwwwwreneeeerenwwwwwrenwwwwwrenwwwwwreserenwwwwwreserenwwwwwreneeeereneeeereneeeereneeeerenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwwrenwwwwwrenwwwwwrenwwwwwrenwwwwwrenwwwwwrewwwwwreneeeerewwwwrenwwwwrenwwwwrewwwwwrewwwwrenwwwwrenwwwwreneeeerenwwwwwrenwwwwwrenwwwwwrenwwwwwreserenwwwwwreserenwwwwwreneeeereneeeereneeeerenwwwwrenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwwrewwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrewwwwwrewwwwrenwwwwrenwwwwreneeeerenwwwwwrenwwwwwrenwwwwwrenwwwwwreserenwwwwwreserenwwwwwreneeeereneeeereneeeereneeeerenwwwwrenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwwrewwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwrewwwwwrewwwwrenwwwwrenwwwwreneeeerenwwwwwrenwwwwwrenwwwwwrenwwwwwreserenwwwwwreserenwwwwwreneeeereneeeereneeeereneeeereneeeerenwwwwrenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrewwwwrenwwwwwrewwwwwreneeeerenwwwwrenwwwwrenwwwwrenwwwwrewwwwwrenwwwwwrenwwwwwrenwwwwwreserenwwwwwreneeeereneeeereneeeereneeeereneeeerenwwwwrenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwrewwwwwreneeeerenwwwwrenwwwwrenwwwwrewwwwwrenwwwwwrenwwwwwrenwwwwwreserenwwwwwreneeeereneeeereneeeereneeeerenwwwwrenwwwwreneeeerenwwwwwreneeeerewwwwrenwwwwrenwwwwrenwwwwrenwwwwrenwwwwrenwwwwrenwwwwre

Finally in phase 3 we simply read from the blackboard in room H:

r

The approach detailed here uses 18 lines of commands and 1830 commands in total. If you’ve found a way to solve the puzzle using fewer lines or fewer commands, please contact us at [email protected]. We’d love to hear from you!