Welcome to the scheduling utilities team. This module merges closed integer intervals [start, end]. Overlapping and touching intervals merge; the input is unsorted and the output must be sorted by start.
Welcome to the scheduling utilities team. This module merges closed integer intervals [start, end]. Overlapping and touching intervals merge; the input is unsorted and the output must be sorted by start.
There is one ticket below. Fix as much of it as you can in 35 minutes. It is graded by several separate checks, so each part of the behaviour you get right counts.
[1,2] and [2,3] touch and merge into [1,3].Merging produces wrong results on unsorted input, and intervals that touch at a boundary are left separate. The ordering step returns the input unchanged, and the overlap test is strict, so a shared endpoint does not count as an overlap.
merge([[1,3],[2,4],[8,10],[4,6]]) is [[1,6],[8,10]].merge([[1,2],[2,3]]) is [[1,3]].merge([[5,6],[1,2]]) is [[1,2],[5,6]].Keep the public function merge.
intervals.py (merge) and ordering.py (by_start, which orders intervals before merging). The shipped regression tests are in tests/visible/; every one of them fails until the bugs are fixed.pytest tests/visible.Adapted from treasure567/bloomberg-practice (round-1/pike @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
interval-merge-unsorted-and-touching
Changes under src/ are evaluated.