aoc
/
2022
1
0
Fork 0
This commit is contained in:
Sijmen 2022-12-04 11:10:52 +01:00
parent 5c997bb158
commit cc1c962067
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
1 changed files with 14 additions and 0 deletions

14
day04.py Normal file
View File

@ -0,0 +1,14 @@
import fileinput
part1, part2 = 0, 0
for line in fileinput.input():
a, b = line.split(",", 1)
a1, a2 = [int(x) for x in a.split("-", 1)]
b1, b2 = [int(x) for x in b.split("-", 1)]
part1 += (a1 >= b1 and b2 >= a2) or (b1 >= a1 and a2 >= b2)
part2 += a1 <= b2 and a2 >= b1
print(part1, part2)