From e2a6b4ac0e4a2723a2ceafc100bbf36c34b18ed8 Mon Sep 17 00:00:00 2001 From: kwout Date: Fri, 1 Dec 2023 19:23:56 -0500 Subject: [PATCH] 2022 4b solved --- 2022/4.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/2022/4.py b/2022/4.py index a8e0a5b..468e90c 100644 --- a/2022/4.py +++ b/2022/4.py @@ -1,6 +1,7 @@ pairs = [[[int(n) for n in m.split("-")] for m in l.split(",")] for l in [i for i in open("input.txt", 'r').read().splitlines()]] sum = 0 +sum2 = 0 for p in pairs: if p[0][0] <= p[1][0] and p[0][1] >= p[1][1]: @@ -8,4 +9,10 @@ for p in pairs: elif p[0][0] >= p[1][0] and p[0][1] <= p[1][1]: sum += 1 -print(sum) \ No newline at end of file + if p[0][0] <= p[1][1] and p[0][1] >= p[1][0]: + sum2 += 1 + elif p[1][0] <= p[0][1] and p[1][1] >= p[0][0]: + sum2 += 1 + +print(sum) +print(sum2) \ No newline at end of file