6 kyu

Roman Numerals Decoder

15,758 of 50,930jhoffner

Description:

Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral.

Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skipping any 0s. So 1990 is rendered "MCMXC" (1000 = M, 900 = CM, 90 = XC) and 2008 is rendered "MMVIII" (2000 = MM, 8 = VIII). The Roman numeral for 1666, "MDCLXVI", uses each letter in descending order.

Example:

"MM"      -> 2000
"MDCLXVI" -> 1666
"M"       -> 1000
"CD"      ->  400
"XC"      ->   90
"XL"      ->   40
"I"       ->    1

Help:

Symbol    Value
I          1
V          5
X          10
L          50
C          100
D          500
M          1,000

Courtesy of rosettacode.org

Algorithms

Stats:

CreatedJun 10, 2013
PublishedJun 10, 2013
Warriors Trained123150
Total Skips21127
Total Code Submissions225083
Total Times Completed50930
JavaScript Completions15758
CoffeeScript Completions138
Ruby Completions1817
Python Completions14307
Haskell Completions637
C# Completions4184
PHP Completions2036
TypeScript Completions2378
Swift Completions903
C++ Completions4158
R Completions206
Nim Completions48
Go Completions2246
Elixir Completions282
Lua Completions240
Scala Completions268
Clojure Completions169
Kotlin Completions913
F# Completions71
C Completions750
CommonLisp Completions39
Dart Completions313
Rust Completions274
Total Stars2040
% of votes with a positive feedback rating91% of 4957
Total "Very Satisfied" Votes4203
Total "Somewhat Satisfied" Votes658
Total "Not Satisfied" Votes96
Ad
Contributors
  • jhoffner Avatar
  • Azuaron Avatar
  • Osmosis Avatar
  • suic Avatar
  • bstenzel Avatar
  • JDeBolt Avatar
  • brunolm Avatar
  • donaldsebleung Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • docgunthrop Avatar
  • mschwettmann Avatar
  • Kiwii Avatar
  • Voile Avatar
  • Madjosz Avatar
  • neilm Avatar
  • mentalplex Avatar
  • imatmati Avatar
  • metagn Avatar
  • gilbertgeorge Avatar
  • Awesome A.D. Avatar
  • konkath Avatar
  • hobovsky Avatar
  • agraboso Avatar
  • xavierguihot Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • gargamel Avatar
  • kadi05 Avatar
  • BrainHorse Avatar
  • lucas.pk16 Avatar
  • __eloise__ Avatar
  • dfhwze Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
  • mariocanfly Avatar
Ad