31. Unary to decimal
The cold lingered longer that winter, as if Dorpat itself were reluctant to move on. Snow no longer fell, yet it did not melt either; it only compressed, layer upon layer, into something denser, harder, more deliberate.
Mihkel noticed this as he walked with Liina along the riverbank. She carried a narrow wooden board wrapped in cloth, held carefully, like something fragile though it bore no obvious cracks.
„They used this to count sheep,“ she said, unwrapping it. Shallow notches ran along the edge—vertical cuts, unevenly spaced, some deeper than others.
„The old men trust this more than numbers written in ink,“ she added. „Each mark is one animal. Nothing hidden. Nothing implied.“
Mihkel ran his thumb over the grooves. Unary. Crude, they would say. Primitive. And yet—unmistakably exact.
That night, Mihkel sat alone in his workshop, the wooden tally resting beside the Logic Mill. He did not uncover the machine immediately. For once, he hesitated.
Unary numbers had always felt honest to him. One stroke per thing. No compression. No illusion of scale. To count was to witness.
Decimal numbers, by contrast, were elegant—and dangerous. Ten symbols standing in for uncounted multitudes. Accepted everywhere. Trusted without question.
To convert was easy. To convert without erasing the act of counting—that was harder.
On the input tape you’ll get a number in unary format (in the range 1-2000). Your task is to output it as a decimal number.
For example, if the input tape is |||| the output tape should be 4.