We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c0e1903 + 4944c51 commit 70999c5Copy full SHA for 70999c5
Basic Scripts/rom_to_dec.py
@@ -0,0 +1,23 @@
1
+
2
+tallies = {
3
+ 'I': 1,
4
+ 'V': 5,
5
+ 'X': 10,
6
+ 'L': 50,
7
+ 'C': 100,
8
+ 'D': 500,
9
+ 'M': 1000,
10
+ # specify more numerals if you wish
11
+}
12
13
+def RomanNumeralToDecimal(romanNumeral):
14
+ sum = 0
15
+ for i in range(len(romanNumeral) - 1):
16
+ left = romanNumeral[i]
17
+ right = romanNumeral[i + 1]
18
+ if tallies[left] < tallies[right]:
19
+ sum -= tallies[left]
20
+ else:
21
+ sum += tallies[left]
22
+ sum += tallies[romanNumeral[-1]]
23
+ return sum
0 commit comments