That's because you're not supposed to count the times the robot has to move, intended method (and much more satisfying) is to create an algorithm that can solve the maze automatically using the variables.