This is a representation of a self-avoiding walk in a grid.
The walk is generated by randomly choosing a direction to move in. If a path reaches a dead end, the path is moved back a random amount of steps.
Since this is even worse than a brute force attempt, it is almost guaranteed that anything larger than 6x6 will not end.