AoC 2022 D4: Camp Cleanup
| Problem statement | Source code | Tags: Data structures
← Previous Back to AoC Index Next →
Part 1
Let the two ranges be and . One range fully contains the other if and only if and , or and .
GHC.Utils.Misc has a useful function count, so the answer is just count contain lines.
Part 2
Two ranges and overlap if and only if they do not satisfy the condition (range 1 is entirely less than 2) or (range 2 is entirely less than 1). In other words, we need and .