Having mastered the puzzles of the bears and wolves, Daring Do found herself in the final chamber before escape and total freedom. However, it was the most heinous of traps, which nopony before her had ever solved: the Chamber of the Cursèd Code.
Sandbar looks up from the hoofwritten outline and turns to Rainbow Dash. “Quibble Pants wrote all this?”
“All sixty-four pages,” Rainbow laments. “I can appreciate the effort, but there’s a lot better work out there?”
“Like yours?” Gallus asks
“Exactly … I mean, yeah, there’re so many others that … you know … are better handled to …”
Not wanting to continue watching her professor writhe in mental agony, Ocellus refocuses back to the story, reading aloud for those unable to crowd around the desk:
Daring observes the room, her body shivering at the shattered bones of so many previous adventurers strewn about the room. Shaking off the macabre images of those unfortunate souls, she catches sight of a large bin containing … children’s blocks? ‘A strange medium’, she thinks to herself when musing about the inner-workings of the mind of the logitaur. ‘What to do with these’ … but the notes she had acquired had already prepared her for this final challenge.
In a recess of the far wall, she makes out some sort of contraption, with a shelf capable of holding a number of the small blocks, but an ominous nozzle from some sort of weapon pointing directly at where one would have to stand to place said blocks. ‘Looks like the others also had only one attempt at this’, she ponders as she pulls the notes from her bag.
“If X represents any sequence of blocks, then LXR will lead to X. Further, if X leads to Y, then note the following: KX leads to YL, QX leads to YR, DX leads to Y ‘doubled’, and CX leads to Y ‘curtailed’ … find the sequence that leads to itself.”
‘Find the sequence that leads to itself’ … she repeats the phrase over and over, pondering how to crack this infernal code …
Ocellus looks up. “That’s it? Where’s the rest of it?”
“Quibble didn’t send me the rest … all he cares about right now is that this final puzzle he created has a unique solution.”
The students turn to each other quizzically. “What would he care about that for?” Smolder asks.
“Probably still bitter about the last time he came across a puzzle like this.”
“You mean, like in another book or something?”
“Uh, yeeeah, something like that,” Rainbow replies to Sandbar, careful not to mention the true ‘something’. “He’s something of a picky perfectionist. So anyway, can you guys help?”
The students take another look at the page containing the puzzle’s description. “Yona confused.”
“I have some experience with this, so I can demonstrate.”
“Really?” Gallus asks. “You read the same puzzle books as this friend of yours?”
“Uh, again, something like that,” Rainbow carefully replies before going to the board and fitting a hoof-glove with a piece of chalk cradled within, allowing her to speak as she writes.
“So ‘X’ and ‘Y’ each mean any sequence of letters. If we take the word PONY, for example, the first line means that LPONYR would return PONY. It’s like a machine, where LPONYR is the thing you put in and PONY is the thing you get out.”
“So it’s basically a function, where LPONYR is the input and PONY is the output,” Ocellus states.
“Yeah, sure, if that helps. So like, that works for anything that starts with ‘L’ and ends with ‘R’. So LYAKR would return YAK, LDRAGONR would return DRAGON, and so on.”
“OK, Yona less confused.”
“What about the other lines,” Silverstream asks.
“The other lines all begin with knowing some in-and-out pair, like LPONYR and PONY. Putting a ‘K’ before the former returns the latter with an ‘L’ at the end, so KLPONYR would return PONYL. Also, KLYAKR would return YAKL, and … you get the idea.”
“And the same for ‘Q’, right?” Ocellus asks. “So, QLPONYR would return PONYR?”
“Hey, you catch on quick … guess I shouldn’t be surprised about that by now, should I?”
“What about the other lines?” Gallus asks.
“ ‘Doubled’ means repeated, so DLPONYR would return PONYPONY. And ‘curtailed’ means cutting off the end, so CLPONYR would return PON.”
“And you can combine those later lines, right?” Ocellus continues. “So, QKLPONYR would return PONYLR, and DQKLPONYR would return PONYLRPONYLR, and CDQKLPONYR would return PONYLRPONYL, and …” She catches herself before going any further.
“So what’s the point of all this?” Smolder asks.
“ ‘Find the sequence that leads to itself’ … Daring Do has to find a sequence that returns the same sequence you put in.”
“So, the output matches the input: it’s a ‘fixed point’, right?” Ocellus asks.
“Exactly!” Rainbow exclaims, hiding her own confusion regarding those terms.
“Professor?” Gallus asks, “Who would want to pick up an adventure novel just to solve puzzles?”
Rainbow shrugs. “It takes all kinds, I guess. So can you guys help?”
The group ponder the puzzle for some time …
I think you made a mistake here. Shouldn't "KLPONYR" return "PONYL"?
9533519
I did, and I fixed. Thank you for catching that.
I'm starting to think I need to hire proofreaders for these stories.
Once again, full solution ahead. This was fun to toy around with.
Let's start by counting the length of the input sequence vs the output sequence, because any fixed sequence will need to stay the same length. For the following, assume that X is a sequence of length n, and that Y is a sequence of length m. Then,
LXR -> X (n+2 -> n)
KX -> YL (n+1 -> m+1)
QX -> YR (n+1 -> m+1)
DX -> YY (n+1 -> 2m)
CX -> Y "curtailed" (n+1 -> m-1)
Now, note that if a sequence does not contain some subsequence of the form LxR, we have no starting point to discover the output. Therefore, the answer must contain a subsequence of the form LxR for some x. In addition, if our sequence ends with something other than R, we have no way to know what the output will be. Therefore, our answer must be something of the form yLxR, for some subsequences y and x. Here, x may contain any set of letters, while y may only contain the letters K, Q, D, and C. (As those are the only ones that will keep the output defined.)
Now, the only way to get a K, Q, D, or C to appear in the output of yLxR is if that letter is already inside x. For the moment, let's assume that x does not contain any more L's or R's. Then, for the output to contain an L and R, y must contain both a K and a Q. In addition, for the length of the output to be at least as long as the input, Y must contain a D. (As the LXR transformation loses two letters, and the only way to gain length is by including D.) However, this means x must also contain a D, a K, and a Q. In particular, the length of x is at least three, meaning that after doubling the length of the output will be longer than the input. Therefore, y (and thus x) must also contain at least one C, as aside from the LXR transformation, that's the only way to reduce length.
In short, x and y must both contain at least one copy of K, Q, D, and C. Our rough strategy here is to find something like xLxR for some x. The idea being that we'll apply the L, double, remove the L from the end, and apply the R. This would suggest trying x = QCDK.
And if we evaluate it:
LQCDKR -> QCDK
KLQCDKR -> QCDKL
DKLQCDKR -> QCDKLQCDKL
CDKLQCDKR -> QCDKLQCDK
QCDKLQCDKR -> QCDKLQCDKR
And so, we've got a solution. However, this is not a unique solution! Note that if X -> Y, then both
CQX -> Y
CKX -> Y
From here on out, I'm going to let x denote the subsequence QCDK, as it's going to show up a lot. Anyway, note that what we've shown with our solution sequence also implies that for any other sequence y,
xLyR -> yLyR
Let z be any combination of (CQ) and (CK) doubles. Then, we know that for any X -> Y, that
zX -> Y
In particular, this means
zxLyR -> yLyR
xzLyR -> yLyR
(In fact, we could stick z inside x as well. As long as it's to the left of the L, the result will be the same.) However, if we let y = zx or xz, this means
zxLzxR -> zxLzxR
xzLxzR -> xzLxzR
Which are additional fixed points. In fact, the riddle that Quibble Pants has created yields an infinite number of solutions, and that's without exploring the possibility of having more than one L or R inside our solution. However, all hope is not lost for Quibble's riddle. There is (at least, ignoring the possibility of more than one L or R, I didn't explore that) a unique shortest solution, so by limiting either the number of blocks that can be put on the table or by limiting the number of certain blocks available (that is, only having two C's), he can still have a legitimate puzzle.
I have not read the next chapter, but I have found two answers, though I doubt either is the expected one.
The first is simply V, (or any other letter that has no specific function attached) With no function running, it surely yields itself.
The second is DD. The second D does nothing, and the first duplicates the second, while vanishing itself.
I would like to try to find the actual solution, but cannot avert my gaze from the second solution that I have found, so I will proceed on to the next chapter.
A minor quibble (heh) about voicing, but wouldn't Rainbow Dash use simpler words than "former" and "latter"? Perhaps "input" and "output"?