Skip to content

Commit d0448f4

Browse files
alabeduarteReenaRajani
authored andcommitted
Add roman numerals solution to 08-03-2018 (#50)
1 parent 7250df5 commit d0448f4

File tree

5 files changed

+4580
-0
lines changed

5 files changed

+4580
-0
lines changed

08-03-18/roman-numerals/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v9.2.0

08-03-18/roman-numerals/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Roman Numerals
2+
3+
## Problem Description
4+
5+
The Romans were a clever bunch. They conquered most of Europe and ruled it for
6+
hundreds of years. They invented concrete and straight roads and even bikinis.
7+
One thing they never discovered though was the number zero. This made writing
8+
and dating extensive histories of their exploits slightly more challenging, but
9+
the system of numbers they came up with is still in use today. For example the
10+
BBC uses Roman numerals to date their programmes.
11+
12+
The Romans wrote numbers using letters - I, V, X, L, C, D, M. (notice these
13+
letters have lots of straight lines and are hence easy to hack into stone
14+
tablets).
15+
16+
The Kata says you should write a function to convert from normal numbers to
17+
Roman Numerals. E.g.:
18+
19+
1 -> I
20+
10 -> X
21+
7 -> VII
22+
23+
For a full description of how it works, take a look at
24+
https://en.wikipedia.org/wiki/Roman_numerals
25+
26+
There is no need to be able to convert numbers larger than about 3000 (the
27+
Romans themselves didn't tend to go any higher). Note that you can't write
28+
numerals like "IM" for 999. Wikipedia says: Modern Roman numerals (…) are
29+
written by expressing each digit separately starting with the left most digit
30+
and skipping any digit with a value of zero. To see this in practice, consider
31+
the (…) example of 1990. In Roman numerals 1990 is rendered: 1000=M, 900=CM,
32+
90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII.
33+
34+
Here are a few more examples you can use as test cases:
35+
36+
1954 -> MCMLIV
37+
1990 -> MCMXC
38+
2014 -> MMXIV
39+
40+
# Extension:
41+
42+
Write a function to convert in the other direction, i.e. numeral to digit.

0 commit comments

Comments
 (0)