diff --git a/puzzles/solutions/2022/d04/p1.py b/puzzles/solutions/2022/d04/p1.py index 69e9d35..2d661ad 100644 --- a/puzzles/solutions/2022/d04/p1.py +++ b/puzzles/solutions/2022/d04/p1.py @@ -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__":