The same observations we used for chapter 1 also apply to chapter 2, we simply need to find a more compact way to create a long path with alcoves. We need a main path of about length (40) to make any number up to (10{,}000).
Here's a possible approach that fits on a (10) × (10) grid:
@.....#.#.
#.#.#.#...
.#.#..#.#.
.....#..#.
#.#.#..##.
...#.#.#..
.#.#.#..#.
..#...#.#.
#...#....#
..#..#.#..