A tiny regex challenge solved without another regex

This notebook presents a small challenge a friend of mine asked me (in Python). I'll write Python code valid for versions $\geq$ 3.6, and to show of I use the typing module to have type hints.

Introduction: the problem a friend of mine asked me

The solution I came up with

Let's write a simple function that will read this list of intervals, and compress the ones that are not disjoint.

For instance, when reading [(0, 3), (2, 5)], the second interval is not disjoint from the first one, so both can be compressed to (0, 5), which is disjoint from the next one (7, 10).

Other examples

Conclusion

It was fun!

See GitHub.com/Naereen/notebooks for other notebooks! This one and all the others I wrote are open-source under the MIT License.