update comments
This commit is contained in:
@@ -6,6 +6,7 @@ def find_overlaps(sets: list) -> int:
|
|||||||
"""
|
"""
|
||||||
count the number of sets that overlap
|
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]
|
overlaps = [1 if set.intersection(*pair) else 0 for pair in sets]
|
||||||
return sum(overlaps)
|
return sum(overlaps)
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ def find_subsets(sets: list) -> int:
|
|||||||
"""
|
"""
|
||||||
count the number of sets that fully contain each other
|
count the number of sets that fully contain each other
|
||||||
"""
|
"""
|
||||||
|
# generate a list where ones correlate to subsets of a and b
|
||||||
subsets = [
|
subsets = [
|
||||||
1 if pair[0].issubset(pair[1]) or pair[1].issubset(pair[0]) else 0
|
1 if pair[0].issubset(pair[1]) or pair[1].issubset(pair[0]) else 0
|
||||||
for pair in sets
|
for pair in sets
|
||||||
@@ -28,7 +30,7 @@ def parse_input(data: list) -> list:
|
|||||||
# get a list of section pairs
|
# get a list of section pairs
|
||||||
sections = [sections.split(",") for sections in data.split("\n")]
|
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()
|
sets = list()
|
||||||
for pair in sections:
|
for pair in sections:
|
||||||
a, b = pair[0].split("-")
|
a, b = pair[0].split("-")
|
||||||
|
|||||||
Reference in New Issue
Block a user