MCPcopy Create free account
hub / github.com/careercup/CtCI-6th-Edition-JavaScript / genCombinations

Function genCombinations

chapter06/6.10 - Poison/poison.js:1–13  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1var genCombinations = function() {
2 var answers = [];
3 var recurse = function(current, pointer, array) {
4 if (pointer === array.length) {
5 answers.push(current);
6 } else {
7 recurse(current.concat([array[pointer]]), pointer + 1, array);
8 recurse(current, pointer + 1, array);
9 }
10 };
11 recurse([], 0, ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']);
12 return answers;
13};
14
15var makeTest = function(array) {
16 var tests = {};

Callers 1

poison.jsFile · 0.85

Calls 1

recurseFunction · 0.70

Tested by

no test coverage detected