← Back to Index

Day 4: Part 2

Problem Description

In this part, the goal was to count the number of ranges that fully contain another range. This required a more detailed comparison of the start and end points of each range.

Approach

To tackle this problem, I followed these steps:
1. Reuse Previous Logic: I reused the range parsing logic from Part 1 to maintain consistency.
2. Containment Checking: I iterated through each pair of ranges, checking if one range fully contains another by comparing their start and end points.
3. Count Containments: I maintained a count of how many ranges fully contain another and printed the final count.

This approach builds on the previous logic while adding the complexity of full containment checks.

Key Insights

Concepts and Algorithms Used