Skip to content

Commit ed9278f

Browse files
chenarmurphey
authored andcommitted
additional tests for recursion
[close #86]
1 parent 42db99c commit ed9278f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

app/recursion.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ define(function() {
88

99
permute: function(arr) {
1010

11+
},
12+
13+
fibonacci: function(n) {
14+
15+
},
16+
17+
validParentheses: function(n) {
18+
1119
}
1220
};
1321
});

tests/app/recursion.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ define([
9292
expect(resultStrings.indexOf(a.join('')) > -1).to.be.ok;
9393
});
9494
});
95+
96+
it('you should be able to return the nth number in a fibonacci sequence', function() {
97+
expect(answers.fibonacci(2)).to.eql(1);
98+
expect(answers.fibonacci(6)).to.eql(8);
99+
});
100+
101+
it('you should be able to return the set of all valid combinations of n pairs of parentheses.', function() {
102+
var expected = [ '((()))', '(()())', '(())()', '()(())', '()()()'];
103+
var result = answers.validParentheses(3);
104+
105+
expect(result.length).to.eql(5);
106+
_.each(expected, function(c) {
107+
expect(result).to.contain(c);
108+
});
109+
});
95110
});
96111

97112
});

0 commit comments

Comments
 (0)