Routes on a grid of M North-South streets and N East-West streets
are calculated by this app.
The routes found are sorted by length, the shortest ones being shown first (the five neon
colours are used at random). The app makes 1000 attempts to find routes, using the
"Depth First Search" algorithm, which makes some random choices of directions to try.
There is no guarantee that all routes are found. In fact for most grid there are thousands
of routes. The current screen shows routes.
You can also hover over the settings button to see the number of routes currently
found, and use the settings button to change the values of M and N.
Optimal routes use only North and East steps to get from (0, 0) to (M - 1, N - 1) along
the grid. It is known that there are (M + N - 2)! / ((M - 1)!(N - 1)!) routes in this situation.
For example, the default values of M and N in this app are 5 and 3, leading to 6! / (4!2!) = 15
optimal routes. These are often all found by the app.