4. Unary Multiplication
The scent of straw, manure, and damp wood filled the barn like an old hymn—coarse but honest. Mihkel ducked under a low beam, brushing hay from his coat, eyes adjusting to the dimness. The sheep bleated rhythmically, their pens marked with chalk and patched with new pine boards.
Farmer Juhan, a broad man with a beard like birch bark and hands the size of spades, greeted him with a respectful nod. „You’re the student, aren’t you? From Dorpat. Madli says you’re good with numbers.“
Mihkel smiled modestly. „I can be. What’s troubling you?“
Juhan scratched the back of his head. „I need to build more pens. Each one takes the same number of boards—eight. But now I want twelve pens. I know I could count it up, sure… but what if it were eighty-eight pens? Or if someone changed the number of boards per pen?“ He tapped the side of his temple. „There must be a better way than counting ‘til your eyes fall out.“
Mihkel blinked. It was so simple. So… mundane. Yet the clarity of the task struck him: this was multiplication. Repeated addition. The very structure of it danced in his mind like a fugue.
Eight pens, each with three planks… That’s three, added eight times. Or vice versa.
He nodded. „Let me try something.“
Juhan led him to a small workbench at the back of the barn, where an unused ledger and carpenter’s chalk lay beside half-driven nails. Mihkel laid out a strip of paper and began copying the numbers in unary—a row of vertical lines, then the multiplication mark, then another row.
„It won’t look like numbers“, Mihkel said. „But the Mill understands them.“
He pulled from his satchel a worn, canvas-wrapped bundle—the core assembly of the Logic Mill. Not the full machine, of course—but enough. The gear casing whirred as he turned the crank by hand, slow and steady, feeding the tape in with care. He could hear the familiar ticks, the stuttering rhythm of states changing like a heartbeat.
On the input tape, you'll get two positive numbers in the unary format separated by *
.
Your task is to compute the product of these two numbers.
For example, if the input tape is ||*|||
, your output should be ||||||
(2 × 3 = 6).