You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
486 B
Python

11 months ago
def process_line(line):
f = None
for char in line:
if char in "0123456789":
if not f:
f = char
l = char
return int("".join([f, l]))
with open("day01/data/input100.txt") as infile:
result = sum(map(process_line, infile))
print(result)
print(result == 142)
with open("day01/data/input101.txt") as infile:
result = sum(map(process_line, infile))
print(result)
print(result == 54968)