37. Greatest Common Divisor
The printing house smelled of pine resin and damp paper. Karl stood at his worktable with two uneven stacks of broadsheets before him, each bearing the careful hand of a different parish scribe.
„Eighteen from Põlva," he said, tapping the taller stack. „Twelve from Otepää. And she wants them in equal packets."
He jerked his chin toward Liina, who sat by the window sorting her own notes.
„I’ve tried fives. I’ve tried fours. Every grouping leaves sheets hanging loose."
Johann, draped against the press frame, waved a hand. „Hand them out loose, then."
Liina looked up. „A sheet handed loose is litter. A packet is a gift. Presentation tells people whether you believe your own language is worth holding."
Mihkel stepped closer and studied the two stacks. Eighteen and twelve. Not a question of dividing one by the other. Something quieter: what is the largest measure that lives inside both numbers without disturbing either?
„You don’t want just any grouping," he said. „You want the largest one that fits both."
Liina watched him with recognition— the moment when Mihkel stopped seeing a problem and began seeing a structure. „Can the method help?" she asked, careful not to name the machine in Karl’s presence.
That evening, alone in the workshop, Mihkel marked the tape: eighteen strokes, a comma, twelve strokes. The method was not to build upward but to reduce. Subtract the smaller from the larger. Compare again. Subtract. Compare. A patient narrowing, like two rivers wearing down the same stone until only the stone remained.
He fed the tape and set the Mill in motion. Tonight it felt different. Not like counting. Not like sorting. More like listening: two voices speaking over each other, and the Mill, patiently, stripping away what was merely theirs until only the shared note survived.
He thought of his own life in Dorpat. The German lectures. The Estonian evenings. Two worlds that refused to be bundled neatly, yet somewhere beneath the difference— a common measure.
On the input tape, you’ll get two positive unary numbers separated by a comma. Your task is to find the greatest common divisor and output it in unary form.
The first number is always greater than or equal to the second number.
For example, if the input is ||||||,||||,
the output should be ||, since the greatest common divisor of 6 and 4 is 2.