Every now and then we encounter some Roman numerals written on an old building’s wall or a book’s page. Your job is to refresh your knowledge about the numerals, e.g. by reading this Wikipedia’s entry, and write a two way converter, for instance in the form of getRoman(arabic::Int)::Str
and getArabic(roman::Str)::Int
functions. Below you will find two sets of parallel numbers (based on the Wikipedia’s page) so that you can test your results (your solution should work correctly for the numbers in range [1-3999]).
arabicTest = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 39, 246, 789, 2421, 160, 207, 1009, 1066,
3999, 1776, 1918, 1944, 2025,
1900, 1912]
romanTest = ["I", "II", "III", "IV", "V",
"VI", "VII", "VIII", "IX", "X",
"XI", "XII", "XXXIX", "CCXLVI", "DCCLXXXIX",
"MMCDXXI", "CLX", "CCVII", "MIX", "MLXVI",
"MMMCMXCIX", "MDCCLXXVI", "MCMXVIII", "MCMXLIV", "MMXXV",
"MCM", "MCMXII"]
Good luck.