Day 04 (minified)

This commit is contained in:
Sebastian Seedorf
2022-12-05 10:42:53 +01:00
parent b4fe10e101
commit c3050cb4fe
4 changed files with 9 additions and 2 deletions

3
day04/part1.min.py Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env python3
print(sum(b>=x<=a<=y>=b or y>=a<=x<=b>=y for a,b,x,y in(map(int,l.strip().replace(',', '-').split('-'))for l in open("input.txt"))))

View File

@@ -8,3 +8,4 @@ for line in lines:
s += 1 if b >= x <= a <= y >= b or y >= a <= x <= b >= y else 0
print(s)
print(sum(b >= x <= a <= y >= b or y >= a <= x <= b >= y for a, b, x, y in (map(int, l.strip().replace(',', '-').split('-')) for l in open("input.txt"))))

3
day04/part2.min.py Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env python3
print(sum(x<=a<=y or x<=b<=y or a<=x<= b or a<=y<=b for a,b,x,y in(map(int,l.strip().replace(',', '-').split('-'))for l in open("input.txt"))))