Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 08_recursion_and_dynamic_programming/01_tripleStep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
A child is running up a staircase with n steps and can hop
either 1 step, 2 steps, or 3 steps at a time. Implement a method to
count how many possible ways the child can run up the stairs.
*/

function tripleStep(n) {
// Your code here
}

module.exports = tripleStep;
18 changes: 18 additions & 0 deletions 08_recursion_and_dynamic_programming/01_tripleStep.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const assert = require('chai').assert;
const tripleStep = require('./01_tripleStep');

describe('recursion and dynamic programming', function() {
describe('triple step', function() {
it('should find the number of ways to hop N steps', function() {
assert.equal(tripleStep(3), 4);
})
it('should return 0 for non positive numbers', function() {
assert.equal(tripleStep(-2), 0);
})
it('should return 1 for 0', function() {
assert.equal(tripleStep(0), 1);
})
})
})