MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_089/sol1.py:118–137  ·  view source on GitHub ↗

Calculates and returns the answer to project euler problem 89. >>> solution("/numeralcleanup_test.txt") 16

(roman_numerals_filename: str = "/p089_roman.txt")

Source from the content-addressed store, hash-verified

116
117
118def solution(roman_numerals_filename: str = "/p089_roman.txt") -> int:
119 """
120 Calculates and returns the answer to project euler problem 89.
121
122 >>> solution("/numeralcleanup_test.txt")
123 16
124 """
125
126 savings = 0
127
128 with open(os.path.dirname(__file__) + roman_numerals_filename) as file1:
129 lines = file1.readlines()
130
131 for line in lines:
132 original = line.strip()
133 num = parse_roman_numerals(original)
134 shortened = generate_roman_numerals(num)
135 savings += len(original) - len(shortened)
136
137 return savings
138
139
140if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 2

parse_roman_numeralsFunction · 0.85
generate_roman_numeralsFunction · 0.85

Tested by

no test coverage detected