Day 01 (minified)
This commit is contained in:
@@ -3,12 +3,11 @@ import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
total = 0
|
||||
regexFirst = re.compile(f"^.*?(\\d)")
|
||||
regexLast = re.compile(f"^.*(\\d)")
|
||||
regex = re.compile("\d")
|
||||
|
||||
for line in lines:
|
||||
first = regexFirst.match(line).group(1)
|
||||
last = regexLast.match(line).group(1)
|
||||
first = regex.search(line)[0]
|
||||
last = regex.search(line[::-1])[0]
|
||||
total += int(first + last)
|
||||
|
||||
print(total)
|
||||
|
||||
Reference in New Issue
Block a user