Skip to content

Commit c81e0ba

Browse files
roman-numerals: sync (#514)
* Sync the `roman-numerals` exercise's docs with the latest data. * Sync the `roman-numerals` exercise's metadata with the latest data.
1 parent ca886b0 commit c81e0ba

File tree

3 files changed

+69
-41
lines changed

3 files changed

+69
-41
lines changed
Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,12 @@
1-
# Instructions
1+
# Introduction
22

3-
Write a function to convert from normal numbers to Roman Numerals.
3+
Your task is to convert a number from Arabic numerals to Roman numerals.
44

5-
The Romans were a clever bunch. They conquered most of Europe and ruled
6-
it for hundreds of years. They invented concrete and straight roads and
7-
even bikinis. One thing they never discovered though was the number
8-
zero. This made writing and dating extensive histories of their exploits
9-
slightly more challenging, but the system of numbers they came up with
10-
is still in use today. For example the BBC uses Roman numerals to date
11-
their programmes.
5+
For this exercise, we are only concerned about traditional Roman numerals, in which the largest number is MMMCMXCIX (or 3,999).
126

13-
The Romans wrote numbers using letters - I, V, X, L, C, D, M. (notice
14-
these letters have lots of straight lines and are hence easy to hack
15-
into stone tablets).
7+
~~~~exercism/note
8+
There are lots of different ways to convert between Arabic and Roman numerals.
9+
We recommend taking a naive approach first to familiarise yourself with the concept of Roman numerals and then search for more efficient methods.
1610
17-
```text
18-
1 => I
19-
10 => X
20-
7 => VII
21-
```
22-
23-
There is no need to be able to convert numbers larger than about 3000.
24-
(The Romans themselves didn't tend to go any higher)
25-
26-
Wikipedia says: Modern Roman numerals ... are written by expressing each
27-
digit separately starting with the left most digit and skipping any
28-
digit with a value of zero.
29-
30-
To see this in practice, consider the example of 1990.
31-
32-
In Roman numerals 1990 is MCMXC:
33-
34-
1000=M
35-
900=CM
36-
90=XC
37-
38-
2008 is written as MMVIII:
39-
40-
2000=MM
41-
8=VIII
42-
43-
See also: http://www.novaroma.org/via_romana/numbers.html
11+
Make sure to check out our Deep Dive video at the end to explore the different approaches you can take!
12+
~~~~
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Description
2+
3+
Today, most people in the world use Arabic numerals (0–9).
4+
But if you travelled back two thousand years, you'd find that most Europeans were using Roman numerals instead.
5+
6+
To write a Roman numeral we use the following Latin letters, each of which has a value:
7+
8+
| M | D | C | L | X | V | I |
9+
| ---- | --- | --- | --- | --- | --- | --- |
10+
| 1000 | 500 | 100 | 50 | 10 | 5 | 1 |
11+
12+
A Roman numeral is a sequence of these letters, and its value is the sum of the letters' values.
13+
For example, `XVIII` has the value 18 (`10 + 5 + 1 + 1 + 1 = 18`).
14+
15+
There's one rule that makes things trickier though, and that's that **the same letter cannot be used more than three times in succession**.
16+
That means that we can't express numbers such as 4 with the seemingly natural `IIII`.
17+
Instead, for those numbers, we use a subtraction method between two letters.
18+
So we think of `4` not as `1 + 1 + 1 + 1` but instead as `5 - 1`.
19+
And slightly confusingly to our modern thinking, we write the smaller number first.
20+
This applies only in the following cases: 4 (`IV`), 9 (`IX`), 40 (`XL`), 90 (`XC`), 400 (`CD`) and 900 (`CM`).
21+
22+
Order matters in Roman numerals!
23+
Letters (and the special compounds above) must be ordered by decreasing value from left to right.
24+
25+
Here are some examples:
26+
27+
```text
28+
105 => CV
29+
---- => --
30+
100 => C
31+
+ 5 => V
32+
```
33+
34+
```text
35+
106 => CVI
36+
---- => --
37+
100 => C
38+
+ 5 => V
39+
+ 1 => I
40+
```
41+
42+
```text
43+
104 => CIV
44+
---- => ---
45+
100 => C
46+
+ 4 => IV
47+
```
48+
49+
And a final more complex example:
50+
51+
```text
52+
1996 => MCMXCVI
53+
----- => -------
54+
1000 => M
55+
+ 900 => CM
56+
+ 90 => XC
57+
+ 5 => V
58+
+ 1 => I
59+
```

exercises/practice/roman-numerals/.meta/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
".meta/uRomanNumeralsExample.pas"
1717
]
1818
},
19-
"blurb": "Write a function to convert from normal numbers to Roman Numerals.",
19+
"blurb": "Convert modern Arabic numbers into Roman numerals.",
2020
"source": "The Roman Numeral Kata",
21-
"source_url": "http://codingdojo.org/cgi-bin/index.pl?KataRomanNumerals"
21+
"source_url": "https://codingdojo.org/kata/RomanNumerals/"
2222
}

0 commit comments

Comments
 (0)