Skip to content

Latest commit

 

History

History
executable file
·
38 lines (28 loc) · 652 Bytes

w05d2.md

File metadata and controls

executable file
·
38 lines (28 loc) · 652 Bytes

Assessment

Week 5 | Day 2

Roman Numerals

In Ruby, write a function transfrom that will transform numerals to romans and vice versa

For example, given the following input:

["III", 29, 38, "CCXCI", 1999]

The correct output is:

[3, "XXIX", "XXXVIII", 291, "MCMXCIX"]

If you're not familiar with or need a refresher on Roman numerals, the rules are simple. First, there are seven letters associated with seven values:

I = 1
V = 5
X = 10
L = 50
C = 100
D = 500
M = 1000

You can combine letters to add values, by listing them largest to smallest from left to right:

II   is 2
VIII  is 8
XXXI is 31