feat(solution): problem #89

main
steven 2023-08-02 13:20:05 -04:00
parent 8722d0a963
commit 12b6a7cad6
3 changed files with 2027 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
from romandata import *
import roman
romanTable = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000,'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900}
def roman_to_int(romanStr):
n = 0
i = 0
while i < len(romanStr):
if i + 1 < len(romanStr) and romanStr[i:i + 2] in romanTable:
n += romanTable[romanStr[i:i + 2]]
i += 2
else:
n += romanTable[romanStr[i]]
i += 1
return n
charactersSaved = 0
for i in dataTable:
lengthOriginal = len(i)
lengthMinimal = len(roman.toRoman(roman_to_int(i)))
charactersSaved += lengthOriginal - lengthMinimal
print(charactersSaved)