Suppose I’ve a square of size (2n+1)x(2n+1) for some n i.e. a square with odd side length.
Starting from the centermost cell I’m interested in counting the no. of ways of reaching any edge cell(as shown in the following figure).
Only non-overlapping paths are allowed i.e. we can not revisit a cell if it has been visited already.
Following Figure shows a square with side 9(n=4) and two possible paths of length 5.

I think all paths will be of length range: [n to (2n-1)^2+1 ]
Counting no. of Paths of Length:
1 – 0
2 – 0
3 – 0
4 – 4
5 – 32
6 – …?
But as the Path length increases I can’t seem to unwrap all the possibilities. I know the symmetry comes into play here but is there any structured way to count all the paths?
Thanks,
To find paths that start at the center of the square board and finish at the borders, you can use a tweaked DFS (Depth First Search) where you will store already visited tiles so you don’t step on them again.
There is indeed a lot of symmetry in the board. You can divide the number of searched paths by 4 just by noticing that:
Up,Down,Left,RightUp generate all other paths startingDown,Left,Right by rotationOnce you do that, you can go further by noticing that:
U, you can goU,LorRLare the same ones generated when you goRby mirror symmetry.You can repeat this several times until you reach the border of the square. The full amount of paths starting by going
Uwill be:U-U-U-U(one path)U-U-U-LU-U-LU-LOnce you count those, you have the full amount of paths by multiplying by four.