Equilibrium index: Difference between revisions
Content added Content deleted
(→JS ES6 Functional: Restored and updated a functional version which returns all equilibrium indices) |
m (→ES6 Functional) |
||
Line 1,309: | Line 1,309: | ||
// ------------------------TEST------------------------ |
// ------------------------TEST------------------------ |
||
const main = () => { |
const main = () => { |
||
console.log(JSON.stringify( |
console.log(JSON.stringify([ |
||
[ |
[-7, 1, 5, 2, -4, 3, 0], |
||
[2, 4, 6], |
|||
[2, 9, 2], |
|||
[1, -1, 1, -1, 1, -1, 1], |
|||
[1], |
|||
[] |
|||
⚫ | |||
[] |
|||
⚫ | |||
)); |
|||
// -> [[3, 6], [], [1], [0, 1, 2, 3, 4, 5, 6], [0], []] |
// -> [[3, 6], [], [1], [0, 1, 2, 3, 4, 5, 6], [0], []] |
||
}; |
}; |
||
Line 1,385: | Line 1,383: | ||
ys => Array.from({ |
ys => Array.from({ |
||
length: Math.min(xs.length, ys.length) |
length: Math.min(xs.length, ys.length) |
||
}, (_, i) => |
}, (_, i) => Tuple(xs[i])(ys[i])); |
||
// MAIN --- |
// MAIN --- |