Cleaning.

This commit is contained in:
Mikael CAPELLE 2022-12-06 15:28:46 +01:00
parent 7cb8317659
commit 4192c98bba
3 changed files with 3 additions and 4 deletions

View File

@ -14,7 +14,7 @@ for line in lines:
values[-1] += int(line.strip()) values[-1] += int(line.strip())
# part 1 # part 1
print(f"max is {max(values)}") print(f"answer 1 is {max(values)}")
# part 2 # part 2
print(f"sum of top 3 is {sum(sorted(values)[-3:])}") print(f"answer 2 is {sum(sorted(values)[-3:])}")

View File

@ -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] 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}") print(f"score 1 is {score_1}")
score_2 = sum(bool(s1.intersection(s2)) for s1, s2 in sections) score_2 = sum(bool(s1.intersection(s2)) for s1, s2 in sections)

View File

@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import itertools
import sys import sys
data = sys.stdin.read().strip() data = sys.stdin.read().strip()