Equilibrium index: Difference between revisions

m
(→‎JS ES6 Functional: Restored and updated a functional version which returns all equilibrium indices)
Line 1,309:
// ------------------------TEST------------------------
const main = () => {
console.log(JSON.stringify([
[-7, 1, 5, 2, -4, 3, 0],
[-7, 1, 5, 2, -4, 3, 06],
[2, 49, 62],
[1, -1, 1, -1, [21, 9-1, 21],
[1, -1, 1, -1, 1, -1, 1],
[1],
].map(equilibriumIndices)));
[]
].map(equilibriumIndices)
));
// -> [[3, 6], [], [1], [0, 1, 2, 3, 4, 5, 6], [0], []]
};
Line 1,385 ⟶ 1,383:
ys => Array.from({
length: Math.min(xs.length, ys.length)
}, (_, i) => [Tuple(xs[i], )(ys[i]]));
 
// MAIN ---
9,655

edits