From 32a1220072cedf7a2db41d169f01f0cad04b242e Mon Sep 17 00:00:00 2001 From: Mikael CAPELLE Date: Tue, 6 Dec 2022 15:28:46 +0100 Subject: [PATCH] Cleaning. --- 2022/day1.py | 4 ++-- 2022/day4.py | 2 +- 2022/day6.py | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/2022/day1.py b/2022/day1.py index af1a525..f29847d 100644 --- a/2022/day1.py +++ b/2022/day1.py @@ -14,7 +14,7 @@ for line in lines: values[-1] += int(line.strip()) # part 1 -print(f"max is {max(values)}") +print(f"answer 1 is {max(values)}") # part 2 -print(f"sum of top 3 is {sum(sorted(values)[-3:])}") +print(f"answer 2 is {sum(sorted(values)[-3:])}") diff --git a/2022/day4.py b/2022/day4.py index ca54f41..efc98b3 100644 --- a/2022/day4.py +++ b/2022/day4.py @@ -12,7 +12,7 @@ def make_range(value: str) -> set[int]: sections = [tuple(make_range(part) for part in line.split(",")) for line in lines] -score_1 = sum(s1.intersection(s2) in (s1, s2) for s1, s2 in sections) +score_1 = sum(s1.issubset(s2) or s2.issubset(s1) for s1, s2 in sections) print(f"score 1 is {score_1}") score_2 = sum(bool(s1.intersection(s2)) for s1, s2 in sections) diff --git a/2022/day6.py b/2022/day6.py index 026dffd..1074273 100644 --- a/2022/day6.py +++ b/2022/day6.py @@ -1,6 +1,5 @@ # -*- encoding: utf-8 -*- -import itertools import sys data = sys.stdin.read().strip()