Skip to content

Commit ce1f570

Browse files
committed
Pass search start index instead of creating another variable
1 parent 232e2dd commit ce1f570

File tree

1 file changed

+1
-2
lines changed
  • puzzles/solutions/2023/d01

1 file changed

+1
-2
lines changed

puzzles/solutions/2023/d01/p2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ def _convert_digits_names_to_numbers(input_text: str) -> str:
1616
for line in input_text.splitlines():
1717
new_line = line[0]
1818
for i in range(1, len(line)):
19-
current_part_of_line = line[: i + 1]
2019
new_line += line[i]
2120
for digit_name in DIGITS_NAMES_TO_NUMBERS:
22-
if current_part_of_line.endswith(digit_name):
21+
if line.endswith(digit_name, 0, i + 1):
2322
new_line += DIGITS_NAMES_TO_NUMBERS[digit_name]
2423
new_text += new_line + "\n"
2524
return new_text

0 commit comments

Comments
 (0)