Ruby
Python
JavaScript

Search for '{{search_term}}'

Exercise: Match Roman numbers

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

Exercise: Match Roman numbers

I usually give this as a bonus exercise for people who finish all the other exercises early. Let's see if you can do this?

Write a function that return "true" if the given value is a Roman number. Can you even write a Roman to "normal" (also known as Arabic) number converter?

Roman numbers are:

I    = 1
II   = 2
III  = 3
IV   = 4
V    = 5
VI   = 6
VII  = 7
VIII = 8
IX   = 9
X    = 10
...

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

Tools

Solution

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus