Как найти число 136 выбором 1-го с каждого массива и их суммированием?
const circle_1 = [7, 2, 3, 5, 16, 50, 25, 40],
circle_2 = [2, 5, 10, 30, 25, 3, 10, 25],
circle_3 = [25, 10, 2, 10, 5, 2, 10, 5],
circle_4 = [7, 2, 3, 20, 3, 7, 2, 5],
circle_5 = [2, 20, 1, 7, 25, 1, 25],
circle_6 = [3];
const CIRCLES = [circle_1, circle_2, circle_3, circle_4, circle_5, circle_6];
let R = [];
function get_sum(s, ind, condidats){
if (ind >= CIRCLES.length) {
if (s == 136) {
R = [...condidats];
}
}
else {
for (let i in CIRCLES[ind] ){
condidats[ind] = i;
get_sum(s+i, ind+1, condidats);
}
}
}
for (let i in CIRCLES[0]) {
s = get_sum(i, 1, i*(CIRCLES.length));
}