14. Binary to Decimal

The library reading room at the university smelled of damp wool and foreign ink. Outside, the thawing Emajõgi hissed and murmured, but here the silence was broken only by the creak of shelves and the occasional flutter of a German or French journal being consulted, then dropped back with scholarly impatience.

Professor Reichenstein had assigned a curious task to his students: „Translate these tables,“ he said, pointing to pages where binary digits huddled in rows like soldiers, their decimal equivalents waiting beside them. „No memorization, no tricks. Show every step. If you think you understand number systems, prove it by walking from one language into another.“

Johann had scoffed over his teacup afterwards. „Why bother? Merchants don’t trade in ones and zeroes. They sell bread, pigs, apples. Count them as any peasant would.“

Mihkel said nothing. He only traced a fingertip down the table, his mind quickening. Johann was half-right—peasants would never know binary. But the Mill did. And if it was ever to serve more than cloistered riddles, it must learn to speak the world’s arithmetic tongue. Decimal. Ten digits for trade, tax, and testimony.

That night, beneath the dim lamplight of his workshop, Mihkel set out a strip of tape: 1010. Four symbols. A number in the Mill’s native dialect.

He watched the gears turn, the tape advancing slowly, the binary pattern unraveling like a poem translated line by line. What began as a sequence of strange, rigid strokes would have to emerge as something familiar— reshaped into the symbols of everyday reckoning, the numbers spoken in marketplaces and written in ledgers.

Outside, the river thawed noisily, ice breaking into fragments that drifted downstream. Inside, the Mill was breaking ice of its own. A bridge was being built—between two tongues, two worlds.

On the input tape, you’ll get a non-negative binary number. Your task is to convert it to a decimal number.

For example, if the input tape is 1010, your output tape should be 10.

Sign in to submit your solution.