File tree 2 files changed +13
-4
lines changed
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change
1
+ IIII
2
+ IV
3
+ IIIIIIIIII
4
+ X
5
+ VIIIII
Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ def parse_roman_numerals(numerals: str) -> int:
40
40
e.g.
41
41
>>> parse_roman_numerals("LXXXIX")
42
42
89
43
+ >>> parse_roman_numerals("IIII")
44
+ 4
43
45
"""
44
46
45
47
num = 0
@@ -64,6 +66,8 @@ def generate_roman_numerals(num: int) -> str:
64
66
e.g.
65
67
>>> generate_roman_numerals(89)
66
68
'LXXXIX'
69
+ >>> generate_roman_numerals(4)
70
+ 'IV'
67
71
"""
68
72
69
73
numerals = ""
@@ -112,18 +116,18 @@ def generate_roman_numerals(num: int) -> str:
112
116
return numerals
113
117
114
118
115
- def solution () -> int :
119
+ def solution (roman_numerals_filename : str = "/p089_roman.txt" ) -> int :
116
120
"""
117
121
Calculates and returns the answer to project euler problem 89.
118
122
119
123
Answer:
120
- >>> solution()
121
- 743
124
+ >>> solution("/numeralcleanup_test.txt" )
125
+ 16
122
126
"""
123
127
124
128
savings = 0
125
129
126
- file1 = open (os .path .dirname (__file__ ) + "/p089_roman.txt" , "r" )
130
+ file1 = open (os .path .dirname (__file__ ) + roman_numerals_filename , "r" )
127
131
lines = file1 .readlines ()
128
132
for line in lines :
129
133
original = line .strip ()
You can’t perform that action at this time.
0 commit comments