Files
python-aoc-2023/day01/part1.py
Sebastian Seedorf 6cdcb4e260 Day 01
2023-12-05 13:26:55 +01:00

15 lines
316 B
Python

#!/usr/bin/env python3
import re
lines = (x.strip() for x in open("input.txt"))
total = 0
regexFirst = re.compile(f"^.*?(\\d)")
regexLast = re.compile(f"^.*(\\d)")
for line in lines:
first = regexFirst.match(line).group(1)
last = regexLast.match(line).group(1)
total += int(first + last)
print(total)