"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
]
},
{
"cell_type":"markdown",
"metadata":{},
"source":[
"# Challenge Notebook"
]
},
{
"cell_type":"markdown",
"metadata":{},
"source":[
"## Problem: Implement an algorithm to have a robot move from the upper left corner to the bottom right corner of a grid.\n",
"\n",
"* [Constraints](#Constraints)\n",
"* [Test Cases](#Test-Cases)\n",
"* [Algorithm](#Algorithm)\n",
"* [Code](#Code)\n",
"* [Unit Test](#Unit-Test)\n",
"* [Solution Notebook](#Solution-Notebook)"
]
},
{
"cell_type":"markdown",
"metadata":{},
"source":[
"## Constraints\n",
"\n",
"* Are there restrictions to how the robot moves?\n",
" * The robot can only move right and down\n",
"* Are some cells off limits?\n",
" * Yes\n",
"* Is this a rectangular grid? i.e. the grid is not jagged?\n",
" * Yes\n",
"* Will there always be a valid way for the robot to get to the bottom right?\n",
" * No, return None\n",
"* Can we assume the inputs are valid?\n",
" * No\n",
"* Can we assume this fits memory?\n",
" * Yes"
]
},
{
"cell_type":"markdown",
"metadata":{},
"source":[
"## Test Cases\n",
"\n",
"<pre>\n",
"o = valid cell\n",
"x = invalid cell\n",
"\n",
" 0 1 2 3\n",
"0 o o o o\n",
"1 o x o o\n",
"2 o o x o\n",
"3 x o o o\n",
"4 o o x o\n",
"5 o o o x\n",
"6 o x o x\n",
"7 o x o o\n",
"</pre>\n",
"\n",
"* General case\n",
"\n",
"```\n",
"expected = [(0, 0), (1, 0), (2, 0),\n",
" (2, 1), (3, 1), (4, 1),\n",
" (5, 1), (5, 2), (6, 2), \n",
" (7, 2), (7, 3)]\n",
"```\n",
"\n",
"* No valid path: In above example, row 7 col 2 is also invalid -> None\n",
"* None input -> None\n",
"* Empty matrix -> None"
]
},
{
"cell_type":"markdown",
"metadata":{},
"source":[
"## Algorithm\n",
"\n",
"Refer to the [Solution Notebook](). If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start."