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:
- C (via Steve132)
- Haskell (plus check out this cool thing from sgronblo using QuickCheck and Parsec)
- Node.js (via Xylem)
- Swift (shout out to wasnotrice)
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.