We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc082d3 commit e13814dCopy full SHA for e13814d
puzzles/solutions/2023/d01/p2.py
@@ -11,6 +11,20 @@
11
)
12
13
14
+def _convert_digits_names_to_numbers(input_text: str) -> str:
15
+ new_text = ""
16
+ for line in input_text.splitlines():
17
+ new_line = line[0]
18
+ for i in range(1, len(line)):
19
+ current_part_of_line = line[: i + 1]
20
+ new_line += line[i]
21
+ for digit_name in DIGITS_NAMES_TO_NUMBERS:
22
+ if current_part_of_line.endswith(digit_name):
23
+ new_line += DIGITS_NAMES_TO_NUMBERS[digit_name]
24
+ new_text += new_line + "\n"
25
+ return new_text
26
+
27
28
def get_answer(input_text: str):
29
input_text = input_text.translate(DIGITS_NAMES_TO_NUMBERS_TRANSLATION_TABLE)
30
return p1.calculate_calibration_values_sum(input_text)
0 commit comments