aboutsummaryrefslogtreecommitdiff
path: root/2022/04/solve.py
diff options
context:
space:
mode:
authorMarvin Borner2022-12-04 06:29:46 +0100
committerMarvin Borner2022-12-04 06:30:34 +0100
commite0dc4f150a95c78bbc129ac5fda00db710f9072f (patch)
tree83b14ceea43ef6c2bdf219d976e789a7d6437d41 /2022/04/solve.py
parent745ee0c0f856ea730ac5bdbbc48de54fd4f05ee9 (diff)
uff
Diffstat (limited to '2022/04/solve.py')
-rw-r--r--2022/04/solve.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/2022/04/solve.py b/2022/04/solve.py
new file mode 100644
index 0000000..664b1bf
--- /dev/null
+++ b/2022/04/solve.py
@@ -0,0 +1,10 @@
+data = [[[int(wtf) for wtf in uff.split("-")] for uff in dat.split(",")] for dat in open("input").readlines() if dat != '']
+
+def part1():
+ return len([42 for a,b in data if a[0] >= b[0] and a[1] <= b[1] or b[0] >= a[0] and b[1] <= a[1]])
+
+def part2():
+ return len([42 for a,b in data if a[0] <= b[1] and b[0] <= a[1]])
+
+print(f"Part 1: {part1()}")
+print(f"Part 2: {part2()}")