Skip to content

Commit

Permalink
Add function that calculates the number of assignment pairs as desired
Browse files Browse the repository at this point in the history
The number of assignment pairs where one range fully contains the other.
  • Loading branch information
katzuv committed Dec 10, 2022
1 parent f234c09 commit 483098e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion puzzles/solutions/2022/d04/p1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ def get_sections(input_text: str) -> tuple[tuple[set[int], set[int]]]:


def get_answer(input_text: str):
raise NotImplementedError
"""Return the number of assignment pairs where one range fully contains the other."""
section_pairs = get_sections(input_text)
return sum(
first_section <= second_section or second_section <= first_section
for first_section, second_section in section_pairs
)


if __name__ == "__main__":
Expand Down

0 comments on commit 483098e

Please sign in to comment.