Skip to content

Commit 8348446

Browse files
committed
better tests
1 parent 23f3cee commit 8348446

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
IIII
2+
IV
3+
IIIIIIIIII
4+
X
5+
VIIIII

project_euler/problem_89/sol1.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def parse_roman_numerals(numerals: str) -> int:
4040
e.g.
4141
>>> parse_roman_numerals("LXXXIX")
4242
89
43+
>>> parse_roman_numerals("IIII")
44+
4
4345
"""
4446

4547
num = 0
@@ -64,6 +66,8 @@ def generate_roman_numerals(num: int) -> str:
6466
e.g.
6567
>>> generate_roman_numerals(89)
6668
'LXXXIX'
69+
>>> generate_roman_numerals(4)
70+
'IV'
6771
"""
6872

6973
numerals = ""
@@ -112,18 +116,18 @@ def generate_roman_numerals(num: int) -> str:
112116
return numerals
113117

114118

115-
def solution() -> int:
119+
def solution(roman_numerals_filename: str = "/p089_roman.txt") -> int:
116120
"""
117121
Calculates and returns the answer to project euler problem 89.
118122
119123
Answer:
120-
>>> solution()
121-
743
124+
>>> solution("/numeralcleanup_test.txt")
125+
16
122126
"""
123127

124128
savings = 0
125129

126-
file1 = open(os.path.dirname(__file__) + "/p089_roman.txt", "r")
130+
file1 = open(os.path.dirname(__file__) + roman_numerals_filename, "r")
127131
lines = file1.readlines()
128132
for line in lines:
129133
original = line.strip()

0 commit comments

Comments
 (0)