This article shows how to implement the set built-in at the expense of a dictionary.
Tunnel excavation involves lots of boring mathematics.