This generates random paths of an appropriate length, then checks that there is a solution by solving it. THIS IS NOT AN ENTRY IN THE COMPETITION. This is for Putney Cat to use to judge entries (and contestants to use to check their solvers). Or maybe to make an actual game with?
If a particular set of early choices is proving too expensive to enumerate a solution from, the code times out and starts again. It usually finds a solution quite quickly. Note: by setting elements of 'grid' initially to something like 2, it should be possible to block certain squares from being included in the path.