update comments

This commit is contained in:
aaron
2022-12-04 14:56:57 +01:00
parent d8464c07fc
commit 35dc133357

View File

@@ -6,6 +6,7 @@ def find_overlaps(sets: list) -> int:
"""
count the number of sets that overlap
"""
# generate a list where ones correlate to intersecting pairs
overlaps = [1 if set.intersection(*pair) else 0 for pair in sets]
return sum(overlaps)
@@ -14,6 +15,7 @@ def find_subsets(sets: list) -> int:
"""
count the number of sets that fully contain each other
"""
# generate a list where ones correlate to subsets of a and b
subsets = [
1 if pair[0].issubset(pair[1]) or pair[1].issubset(pair[0]) else 0
for pair in sets
@@ -28,7 +30,7 @@ def parse_input(data: list) -> list:
# get a list of section pairs
sections = [sections.split(",") for sections in data.split("\n")]
# generate a list of section set pairs
# generate a list of section pairs with sets of discrete ranges
sets = list()
for pair in sections:
a, b = pair[0].split("-")