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.
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!