Recursion with Robot Paths

The Problem:

A robot is located at the top-left corner of a nxn grid. The robot can move either up, down, left, or right, but can not visit the same spot twice. The robot is trying to reach the bottom-right corner of the grid. The number of ways it can reach the bottom-right corner of the grid is?

Make your solution work for a grid of any size.

Example Inputs and Outputs:

Given helper functions:

My solution:

If you have any further questions please comment below and I’ll be more than happy to explain anything else about this problem!

Coming Soon…

In my next blog post I will go more in-depth on what is actually happening when we are recursing and returning from stacks!

Show your support

Clapping shows how much you appreciated Irving Barajas’s story.