Calculates and returns the answer to project euler problem 89. >>> solution("/numeralcleanup_test.txt") 16
(roman_numerals_filename: str = "/p089_roman.txt")
| 116 | |
| 117 | |
| 118 | def 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 | |
| 140 | if __name__ == "__main__": |
no test coverage detected