95. xs.reach(while:, cyclic:) names the two-pointer sweep (2026-11-21)
- Decision. Add
reach(self, while: (T, T) -> Bool, cyclic: Bool = false) -> List<Int>to every sequence: for eachi, the largestksuch thatwhile(xs[i], xs[i + j])holds for every1 <= j <= k(indices taken modlenandk < lenwhencyclic). Cost: O(n) calls ofwhilewhen the reach drops by at most one fromitoi + 1, which holds wheneverwhile(a, ·)is true-then-false along a sorted order; debug builds trap when that is violated. - Why. The hand-written loop
while j < i + m and p(xs[i], xs[j % m]): j += 1with aj = max(j, i + 1)clamp appears in angular sweeps, circular arcs and distance windows (cf1284e and others), and a binary search per element costs a log factor. One method replaces the loop and states the quantity; it is not a cyclic-only helper, andcyclic_spanis not added. - Reverse. Remove
reachfromstd.seq; ports go back to explicit two pointers.