Skip to content

Commit 1a46b76

Browse files
authored
Update main.py
I did almost the same as you two but my read functions saves some braces later on.
1 parent 40658d7 commit 1a46b76

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

day04/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
with open("input.txt") as f:
2-
lines = [[[int(i) for i in k.split("-")] for k in x.split(",")] for x in f]
2+
lines = [[*map(int, x.replace("-", ",").split(","))] for x in f]
33

4-
print(sum(a <= c <= d <= b or c <= a <= b <= d for (a,b), (c,d) in lines))
5-
print(sum(a <= d and b >= c for (a,b), (c,d) in lines))
4+
print(sum(a <= c <= d <= b or c <= a <= b <= d for a, b, c, d in lines))
5+
print(sum(a <= d and b >= c for a, b, c, d in lines))

0 commit comments

Comments
 (0)