Exit
  1. Learn
  2. Check
  3. Solve
  4. Reflect

No label this time

Roman numerals write a number as pieces from a fixed menu: M is 1000, D is 500, C is 100, L is 50, X is 10, V is 5 and I is 1. 1994 is written MCMXCIV. To make it short, the Romans also had pairs where a small piece sits before a bigger one and is taken away: IV is 4, IX is 9, XL is 40, XC is 90, CD is 400 and CM is 900.

A small hint for this one. Put all thirteen pieces in order from biggest to smallest, in two lists that line up: the values and the symbols.

Before coding: what is the menu, and what order should I try it in?
Writing 1994
1000
0
900
1
500
2
400
3
100
4
90
5
50
6
40
7
10
8
9
9
5
10
4
11
1
12
value
n
994
result
M

Start with 1994. The biggest piece that fits is 1000, which is M. Take it away: 994 is left. The text so far is M.

Move 1 of 4