Roman numerals are I, V, X, L, C, D, and M. They correspond to the common (Hindu-Arabic) numbers 1, 5, 10, 50, 100, 500, and 1000, respectively.
Roman numbers are written using these numerals; and are additive in all cases except when I precedes V or X, X precedes L or C, and C precedes D or M.
In these cases, the smaller Roman number is subtracted from the former, viz:
- IV = 4
- IX = 9
- XL = 40
- XC = 90
- CD = 400
- CM = 900
This monorepo contains a few TDD'd samples of Roman to Hindu-Arabic conversions. The purpose is illustrative: how TDD aids in simple design and refactoring.
It's instructive to examine not just the final solution but each individual commit.
This is a monorepo. When you clone it, you'll get small codebases in multiple languages.
Make sure you have node.js installed.
Then, in a shell/terminal window, cd
to the js
directory and run yarn install
followed by yarn run test
.
Make sure you have Ruby installed.
Install the bundler
gem by running gem install bundler
in a shell/terminal window.
Then, in a shell/terminal window, cd
to the ruby
directory and run ruby test_roman.rb
.
Make sure you have Kotlin installed
Linux / MacOS: In a shell/terminal window, cd
to the kotlin
directory and run ./gradlew init
followed by ./gradlew test
Windows: In a cmd window, cd
to the kotlin
directory and run gradlew.bat init
followed by gradlew.bat test
https://en.wikipedia.org/wiki/Roman_numerals
https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_system