January 2018
Intermediate to advanced
332 pages
7h 36m
English
Now that we understand the approach, let's first create the class for our algorithm and add the analyze() method, which will first create the 2D array before generating the algorithm.
When the class is initialized, we will construct our 2D array with all the values in it set to false. We will then use this 2D array and update some of the values within it based on our conditions, which we will discuss shortly:
var _ = require('lodash');class Planner { constructor(rows, cols) { // create a 2d array of rows x cols // all with value false this.planner = _.range(rows).map(() => { return _.range(cols + 1).map(()=> false); }); // holds the response this.outcomes = []; }}module.exports = Planner;
Read now
Unlock full access