Day 04
This commit is contained in:
1000
day04/input.txt
Normal file
1000
day04/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
10
day04/part1.py
Normal file
10
day04/part1.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
lines = (x.strip() for x in open("input.txt"))
|
||||||
|
s = 0
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
a, b, x, y = map(int, line.replace(',', '-').split('-'))
|
||||||
|
s += 1 if b >= x <= a <= y >= b or y >= a <= x <= b >= y else 0
|
||||||
|
|
||||||
|
print(s)
|
||||||
10
day04/part2.py
Normal file
10
day04/part2.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
lines = (x.strip() for x in open("input.txt"))
|
||||||
|
s = 0
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
a, b, x, y = map(int, line.replace(',', '-').split('-'))
|
||||||
|
s += 1 if x <= a <= y or x <= b <= y or a <= x <= b or a <= y <= b else 0
|
||||||
|
|
||||||
|
print(s)
|
||||||
Reference in New Issue
Block a user