Hilbert Curve
Place a dot at each corner of a square and join them with three lines to make a U, which you can follow through all four dots without lifting your pen. To visit more dots, divide the square into four smaller squares and put a smaller U in each. That leaves four separate paths, so their ends have to face one another before you can join them into one.
Below, try rotating route 1 until its filled end sits beside route 2's hollow start. A join should be as short as the other lines, and the dashed joins are too long.
2 of 3 links fit
Once the four paths join, you have a route through sixteen dots, so you can repeat the arrangement with four copies of this new route. Choose the 8 × 8 grid to see this: each colored route now contains four smaller routes, joined in the same way. If you reverse one, its start and end swap places, and the joins beside it stop fitting.
Each round visits four times as many dots, still without lifting the pen or visiting a dot twice.1
Pick a spot in one of the gaps, and as the grid gets finer, the path passes closer to it. In the infinite limit, the path reaches every spot in the square, which is what space-filling means. Every finite drawing still leaves gaps between its lines.
The 3D version does the same inside a cube, joining eight smaller paths, one in each of eight smaller cubes.
Further exploring
Videos
- Space-Filling Curves — Numberphile
- Hilbert’s Curve — 3Blue1Brown
- Coding the Hilbert Curve — The Coding Train