Tries to solve 2d maze with dynamic programming (4 directions)