diff --git a/day04/part1.min.py b/day04/part1.min.py new file mode 100644 index 0000000..65fa374 --- /dev/null +++ b/day04/part1.min.py @@ -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")))) diff --git a/day04/part1.py b/day04/part1.py index 701afb4..6eca20b 100644 --- a/day04/part1.py +++ b/day04/part1.py @@ -7,4 +7,5 @@ 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) \ No newline at end of file +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")))) diff --git a/day04/part2.min.py b/day04/part2.min.py new file mode 100644 index 0000000..3bb4900 --- /dev/null +++ b/day04/part2.min.py @@ -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")))) diff --git a/day04/part2.py b/day04/part2.py index 2e2904d..4f3d4d9 100644 --- a/day04/part2.py +++ b/day04/part2.py @@ -7,4 +7,4 @@ 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) \ No newline at end of file +print(s)