Converting numeral systems

During this session we will explore converting between different numeral systems. The numeral system we commonly use in the West (1,2,3 etc) is called Western Arabic. Although it's actually Hindu (Arabic traders brought it to Europe via India), we will refer to it as Arabic. In central Europe this eventually replaced a simplistic system called Urnfield.

Specification

We require a program that will convert between 3 different numeral systems; Arabic, Roman, Urnfield.

The following ranges are required:

  • Roman: 1..3499
  • Urnfield: 1..29

Roman

Roman numerals are based on seven symbols which can be combined to represent numbers.

Roman Symbol Arabic Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

Generally, Roman numerals are written in descending order from left to right, and are added sequentially, for example MMVI (2006) is interpreted as 1000 + 1000 + 5 + 1.

Urnfield

Urnfield is a simplistic numeral system used around 1200 BC in central Europe. It uses only 2 characters which are both slashes.

Urnfield Symbol Arabic Value
/ 1
\ 5

Each forward slash represents 1 and appears first, there is at most 4. After that downward slashes each represent 5. For example //\\\ (17) is interpreted as 1 + 1 + 5 + 5 + 5.

Example input and output

Example 1: Arabic -> Urnfield  for 1..10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
-> /, //, ///, ////, \, /\, //\, ///\, ////\, \\

Example 2: Arabic -> Urnfield for 10..29
11, 12, 15, 20, 21, 28, 29
-> /\\, //\\, \\\, \\\\, /\\\\, ///\\\\\, ////\\\\\

Example 3: Arabic -> Roman for 1..10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
-> I, II, III, IV, V, VI, VII, VIII, IX, X

Example 4: Arabic -> Roman for 10..100
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 40, 50, 69, 99, 100
-> XI, XII, XIII, XIV, XV, XVI, XVII, XVIII, XIX, XX, XXV, XL, L, LXIX, XCIX, C

Example 5: Arabic -> Roman for 101..3499
101, 150, 200, 400, 500, 666, 1000, 1444, 1666, 1999, 2000, 2009, 3000, 3499
-> CI, CL, CC, CD, D, DCLXVI, M, MCDXLIV, MDCLXVI, MCMXCIX, MM, MMIX, MMM,
       MMMCDXCIX

Example 6: Roman -> Arabic (reverse examples 1..2)

Example 7: Urnfield -> Arabic (reverse examples 3..5)

Examples 8: Roman -> Urnfield
I, II, III, IV, V, VI, VII, VIII, IX, X, XXIX
-> /, //, ///, ////, \, /\, //\, ///\, ////\, \\, ////\\\\\