Number of Paths to get from One point to Another

511 Views Asked by At

grid What are the total number of paths that can be taken to get from point A to point B ? Rules :- 1)You can move up ,down ,left , right 2)You CANNOT return to a point that you have been to before ie no crossing your own path 3)You CANNOT move diagonally

(I have tried a similar problem ,wherein you could move only up or to the right , which was pretty easy) (Also if a general formula can be given for l*b grid , it will be appreciated)

1

There are 1 best solutions below

1
On BEST ANSWER

This is a self avoiding walk problem. There is no known formula for a generic $m \times n$ grid. In fact it is rumored that this is a computationally hard (NP hard problem).

The particular grid of $4\times 4$ is doable. It comes out to be $184$. If it helps, I can upload a small python/matlab script.

NJA Sloane's IS has it listed for a set of grid size $n \times n$, unto $n=10$: http://oeis.org/A007764

There is a nice article on self avoiding walk (aptly titled 'How to avoid yourself') by Brian Hayes in American Scientist (I couldn't find the exact link, but here is a copy sourced in the internet. http://www.peterbeerli.com/classes/images/f/fa/AmSci1998Hayes.pdf)