I think there are 16 distinct paths, as below R1U2R3R4U5R6U7 U1R2U3U4R5U6R7 R1R2U3U4R5R6U7 U1U2R3R4U5U6R7 R1R2U3R4U5U6R7 U1U2R3U4R5R6U7 U1U2R3U4R5R6U7 R1R2U3R4U5U6R7 U1U2R3R4U5U6R7 R1R2U3U4R5R6U7 U1R2U3U4R5U6R7 R1U2R3R4U5R6U7 R1U2U3U4U5R6R7 U1R2R3R4R5U6U7
S
scott mankowitz
@scott mankowitz
Posts
-
Are You Smarter Than A Sixth Grader (Taking Seventh Grade Math)? -
Are You Smarter Than A Sixth Grader (Taking Seventh Grade Math)?Shouldn't it be 16? If there are 8 distinct groups of 3-4 numbers that sum to 14, one path will start with the first move going up and the next will start with the first move going right. Incidentally, here is my code:
function combine(a, min) {
var fn = function(n, src, got, all) {
if (n == 0) {
if (got.length > 0) {
all[all.length] = got;
}
return;
}
for (var j = 0; j < src.length; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
}
return;
}
var all = [];
for (var i = min; i < a.length; i++) {
fn(i, a, [], all);
}
all.push(a);
return all;
}function arr_sum(arr) {
var n = 0;
for (var i = 0; i < arr.length; i++) {
n += arr[i];
}
return n;
}
k=[1,2,3,4,5,6,7];
combine(k, 1).filter(function(v, i) {
return 14 == arr_sum(v)
})