Submit an Entry

To enter the challenge, you need to signup or login.

This Challenge's Best Entries [View All]

(View the Overall | Perl | PHP | Python | Ruby

Rank User Size Language Score [?]
1st eyepopslikeamosquito 53 Ruby 10,000 (v54)
2nd o0lit3 53 Perl 10,000 (v44)
3rd Grimy 53 Perl 10,000 (v1)
4th primo 55 Ruby 9,636 (v22)
5th flagitious 56 Ruby 9,464 (v10)
6th seojay 56 Perl 9,464 (v5)
7th ySas 58 Perl 9,137 (v11)
8th leonid 58 Ruby 9,137 (v24)
9th d310 58 Perl 9,137 (v5)
10th bearstearns 59 Perl 8,983 (v24)

See who is active in this challenge →

Roman to Decimal

(Challenge added over 6 years ago.)

Lazy Cows Don't Moo.

The Problem

In this challenge, you will be given a number in roman numeral form and must print out its integer value.

Recently there was a perl golf challenge relating to roman numerals at Fonality, most people relied on a formula to convert from decimal to roman, so for those who didn't get a chance to enter due to being busy over the holidays or just not knowing perl, here is your chance to get in on the roman numeral action. It should be similar but completely different.

More Information

Roman numerals are composed of the capital letters IVXLCDM corresponding to values 1, 5, 10, 50, 100, 500, 1000. The value of a roman numeral is the sum of each letter's value.

However, Roman numerals are not purely additive. Instead of using four repetitions of a single symbol (For example, using IIII to represent 4), we instead use IV, which can be read as '5 minus 1'. Similarly, we use XC for 90, CD for 400 etc. Note there are some restrictions on this. For example, we don't write IM for 999. For more information, check out Wikipedia's Roman numerals article and Mathworld's Roman numerals page

  • The input will be in the range of I to MMMCMXCIX (1 to 3999)
  • The input will be followed by the newline character.
  • There are 25 test cases. In order for your script to be successful it must pass every case.

Examples

Of the 25 runs your submission will be tested on, the first 17 will always ask you to convert the same numeral :

In the remaining 8 tests, your submission will be given a random numeral to convert. Click here to see a random test case. Reload the page to get another.

Thanks

Thanks to Flagitious for suggesting, submitting and writing the description for this challenge!