ID: aoc-2022-04
1724647305

Overlap of 2 Ranges


      func contains[T](r1, r2: Slice[T]): bool =
        r1.a >= r2.a and r1.b <= r2.b

      func fullyOverlap[T](r1, r2: Slice[T]): bool =
        r1 in r2 or r2 in r1

      func overlapImpl[T](r1, r2: Slice[T]): bool =
        r1.a <= r2.a and r1.b >= r2.a

      func overlap[T](r1, r2: Slice[T]): bool =
        overlapImpl(r1, r2) or overlapImpl(r2, r1)
    
My solution

      FullyOverlap     = 0≥(a-c)×(b-d)
      Partiallyoverlap = 0≥(a-d)×(b-c)
    
https://github.com/codereport/Advent-of-Code-2022/blob/main/day04.apl