Files
davideisinger.com/content/elsewhere/romanize-another-programming-puzzle/index.md
2023-10-22 23:52:56 -04:00

1.8 KiB

title, date, draft, needs_review, canonical_url
title date draft needs_review canonical_url
Romanize: Another Programming Puzzle 2015-03-06T00:00:00+00:00 false true https://www.viget.com/articles/romanize-another-programming-puzzle/

We had such a good time working through our first programming challenge that we decided to put another one together. We had several ideas, but Pat's idea of converting to and from Roman numerals won out, and a few hours later, Romanize was born.

The name of the game is to write, in a language of your choice, a pair of programs that work like this:

> ./deromanize I
1
> ./deromanize II
2
> ./deromanize MCMIV
1904

> ./romanize 1
I
> ./romanize 2
II
> ./romanize 1904
MCMIV

It's a deceptively difficult problem, especially if, like me, you only understand how Roman numerals work in the vaguest sense. And it's one thing to create a solution that passes the test suite, and another entirely to write something concise and elegant -- going from Arabic to Roman, especially, seems to defy refactoring.

We've created working solutions in seven eight nine ten languages:

What's gonna be number eleven? You decide! Fork the repo and give it your best shot. When you're done, send us a PR.