A Roman Numerals Kata
A Kata is a programming exercise we do to obtain mastery of a programming language, programming patterns, or technique. Matt has a modest set of his checked into GitHub, mostly in Ruby (https://github.com/PacktPublishing/Software-Testing-Strategies/tree/main/Chapter03/ruby/romannumeral).
To learn unit testing and TDD, we suggest the Roman Number Kata. The program itself is straightforward – write a console application that takes Roman numerals as input and outputs the Arabic (“regular, decimal”) number.
Roman numerals generally move left to right, with the largest number on the left. Here’s the high-level translation:
- I = One
- V = Five
- X = Ten
- L = Fifteen
- C = One hundred
- D = Five hundred
- M = One thousand
To repeat a number, just add it to itself. III is “three.” However, when you get to one before the next number, things get tricky. You generally use a one in front, reversing...