Skip to content

Commit

Permalink
Merge pull request #1059 from dalaoqi/master
Browse files Browse the repository at this point in the history
Added roman numerals to Integer function
  • Loading branch information
fineanmol authored Oct 21, 2021
2 parents 11cbf93 + 722a1de commit d13836a
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
s = 'MXCIV'

result = 0
last = 0
dic = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}

for i in reversed(s):
if dic[i] >= last:
result += dic[i]
else:
result -= dic[i]

last = dic[i]

print(result)

0 comments on commit d13836a

Please sign in to comment.