30. Palindrome

Christmas came to Dorpat quietly that year. Snow fell not in storms, but in patient layers, smoothing the city’s edges until streets, roofs, and courtyards seemed carved from the same pale block. Bells rang without urgency. Smoke rose straight from chimneys, as if even the wind had agreed to rest.

A knock came, gentle and uncertain.

Johann stepped inside, stamping snow from his boots. He carried no books, no ledgers—only a small parcel wrapped in twine. His usual theatrical air was missing.

„Merry Christmas,“ he said, then hesitated. „Or… whatever we call it when we pretend not to believe.“

Mihkel smiled faintly. „Surely not carols.“

Johann unwrapped the parcel. Inside lay a thin wooden ornament, freshly carved, its surface marked with careful letters burned into the grain:

aba

„The baker’s children made them,“ Johann said. „They say words like this keep bad luck away. Spirits can’t twist them—read it forwards or backwards, it stays the same.“

He laughed, briefly. „I know. Folklore nonsense. But after your… dream about elves and inventories, I thought you might appreciate the symmetry.“

Mihkel turned the ornament slowly in his fingers. The letters were plain. No invocation, no prayer—just structure.

„They trust it because it cannot be altered,“ he said. „Not because it is sacred, but because it is stable.“

Johann blinked. „That sounds dangerously reasonable.“

Mihkel felt the familiar tightening in his chest. Reversal. Reflection. Invariance.

He glanced toward the covered Mill. It had reversed words before. But this was different. Not to change a thing—but to ask whether change mattered at all.

„Let us not argue with superstition,“ he said. „Let us test it.“

That night, with the city hushed beneath snow and church bells fading into memory, Mihkel uncovered the Logic Mill.

On the input tape you’ll get a single word: a sequence of letters a-f, length 1 to 16, with no separators. Your task is to check if it's a palindrome, and output Y (yes) or N (no).

For example, if the input tape is aba the output tape should be Y. More examples: abN, abccbaY.

Sign in to submit your solution.