diff --git a/08_recursion_and_dynamic_programming/02_robotGrid.js b/08_recursion_and_dynamic_programming/02_robotGrid.js new file mode 100644 index 0000000..c6c7e36 --- /dev/null +++ b/08_recursion_and_dynamic_programming/02_robotGrid.js @@ -0,0 +1,12 @@ +/* + Imagine a robot sitting on the upper left corner of grid with r rows and c columns + The robot can only move in two directions, right and down, but certain cells are + 'off limits' such that the robot cannot step on them. Design an algorithm to find + a path for the robot from the top left to the bottom right. +*/ + +function robotGrid(grid) { + // Your code here +} + +module.exports = robotGrid; diff --git a/08_recursion_and_dynamic_programming/02_robotGrid.test.js b/08_recursion_and_dynamic_programming/02_robotGrid.test.js new file mode 100644 index 0000000..5502d4d --- /dev/null +++ b/08_recursion_and_dynamic_programming/02_robotGrid.test.js @@ -0,0 +1,16 @@ +'use strict'; + +const assert = require('chai').assert; +const robotGrid = require('./02_robotGrid'); + +describe('recursion and dynamic programming', function() { + describe('robot grid', function() { + it('should return a valid path', function() { + const matrix = [[0, 0, 0], + [0, 0, 0], + [0, 0, 0]] + + assert.equal(robotGrid(matrix).length, 4); + }) + }) +})