about | help | code help+videos | done | prefs |
Given a string in Roman Numeral Format, return the integer equivalent. You may assume that the string will ONLY contain the symbols listed below and that the symbols were used "properly" using the common modern interpretation of Roman Numerals. That modern interpretation means that the order of the symbols matters, and that the symbols will be in decreasing order of value, with the one exception that a single symbol of a lower value could be in front of another symbol, such as: XIV meaning 10+5-1. The "-1" is because the "I" is in front of the "V". Remember that you can only have ONE such symbol in front per occurrence, but that pattern can occur more than once. So you can have MCD (which means 1000+500-100) and DXL (which means 500+50-10). You could also have CMIX, which would mean 1000+10-100-1. Various symbols and their values are given below. You may assume that these are the only symbols in the string and that they will meet the requirements explained above. I 1 V 5 X 10 L 50 C 100 D 500 M 1000 You might want to write one or more helper methods. Look at the test data for examples. quiz2021_10_12_HL_roam("XL") → 40 quiz2021_10_12_HL_roam("MMMDCCVII") → 3707 quiz2021_10_12_HL_roam("MMMDCCCLXXXVIII") → 3888 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 280
Copyright Nick Parlante 2017 - privacy