Day 4 completed

+ refactored day 1 to 3 with black -l 119
This commit is contained in:
2023-12-04 07:44:36 +01:00
parent 97021a58b2
commit 142696bf6e
7 changed files with 103 additions and 29 deletions

View File

@@ -30,14 +30,14 @@ with open("input.txt") as input:
".*?([0-9]|zero|one|two|three|four|five|six|seven|eight|nine).*([0-9]|zero|one|two|three|four|five|six|seven|eight|nine).*?",
line,
):
#print(match.groups(1))
# print(match.groups(1))
number = int(digits[match.groups(1)[0]] + digits[match.groups(1)[1]])
#print(number)
# print(number)
accumulator += number
elif match := re.match(".*?([0-9]|zero|one|two|three|four|five|six|seven|eight|nine).*?", line):
#print(match.groups(1))
# print(match.groups(1))
number = int(digits[match.groups(1)[0]] + digits[match.groups(1)[0]])
#print(number)
# print(number)
accumulator += number
else:
print(line)