Day 01
This commit is contained in:
14
day01/part1.py
Normal file
14
day01/part1.py
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user