39. Merge Unary Arrays

Liina had borrowed a narrow upstairs room from a widowed sexton on the edge of Dorpat, a place with low beams, a whitewashed stove, and shelves too shallow for any book thicker than a hymnal. It was not an office, nor quite a home. It was one of those temporary rooms in which serious work gathers anyway.

Two bundles of papers lay before her, each tied with faded ribbon. One had come from Võru, the other from Põlva. Folk verses, charms, fragments of songs— copied in different hands, carried by different roads, preserved against different kinds of forgetting.

Each bundle was already arranged. The shorter pieces first, then the longer ones, rising gradually like steps on a wooded hill. Liina had spent days establishing that order.

„Now comes the harder part,“ she said, resting her hand lightly on both stacks. „Not to sort them. To join them. If I lay one parish after the other, it will feel like conquest. If I begin again from disorder, I lose the care already spent.“

Mihkel looked from one bundle to the other. This was not the old pleasure of correcting confusion. Both sequences were already true in themselves. The task was gentler, and for that reason more exacting: to preserve two orders while making one.

Johann, who had accompanied him only to escape his own reading, leaned against the window and peered at the pages.

„Ah,“ he said, „two choirs. And you require one hymn without silencing either side.“

Liina gave him a brief look. „For once, that is almost useful.“

Mihkel allowed himself the smallest smile. Then he drew the prepared tape toward him.

„The Mill need not judge the whole at once,“ he said quietly. „Only the front of each line. What stands nearest. What is ready next. Then again. And again.“

Liina watched him closely. She no longer asked whether method diminished meaning. Her question had grown narrower—and more difficult. Whether method could preserve meaning without laying claim to it.

That evening, alone in the workshop, Mihkel fed the twin arrays into the Logic Mill. Two ordered streams, separated, waiting. The machine began its patient work: compare, choose, advance; compare, choose, advance.

It seemed to him, as he listened, less like calculation than diplomacy.

On the input tape, you’ll get two sorted arrays of unary numbers. Your task is to merge them into one sorted array, preserving ascending order.

The two arrays are separated by a semicolon. Both arrays are already sorted in ascending order. Each array contains one or more positive numbers separated by comma, and duplicate values may appear.

For example, if the input tape is |,|||,|||;||,|||,||||, your output tape should be |,||,|||,|||,|||,||||.

Sign in to submit your solution.

Quest leaderboard
Discuss it on Reddit or Discord
This was the last quest for now.
Get updates about new quests by subscribing to the social media channels or RSS