3 months ago

``````const solve = intArray => {
const rows = intArray.reduce((acc, cur) => {
if (cur.reduce((acc, cur) => cur + acc) > acc) {
return cur.reduce((acc, cur) => cur + acc);
} else return acc;
}, 0);

const columns = intArray
.sort((a, b) => b.length - a.length)[0]
.reduce((acc, cur, index) => {

if (cur + intArray[1][index] + intArray[2][index] > acc) {
return cur + intArray[1][index] + intArray[2][index];
} else return acc;
}, 0);

return rows > columns ? rows : columns;
};``````

a year ago

``````const solve = (intArray) => {
const row = intArray.map((arr) => {
return arr.reduce((a,b) => a + b, 0);
});
const col = [];
for (let i = 0; i < intArray[0].length; i++) {
for (let j = 0; j < intArray.length; j++) {
col[i] = col[i] ? col[i] += intArray[j][i] : col[i] = intArray[j][i];
}
};
return [...row, ...col].sort((a, b) => b - a)[0];
};``````

a year ago

Welcome to Disnyland

``````const solve = (intArray) => {
const largestSumInRows = intArray.reduce((acu, cur) => {
const sum = cur.reduce((ac, cu) => {
return ac + cu;
}, 0);
return sum > acu ? sum : acu;
}, intArray[0][0]);

let largestSumInCols = 0;
let currentColSum = 0;
for (let i = 0; i < intArray[0].length; i++) {
for (let x = 0; x < intArray[0].length; x++) {
currentColSum += intArray[x] ? intArray[x][i] : 0;
}
currentColSum > largestSumInCols
? (largestSumInCols = currentColSum)
: null;
currentColSum = 0;
}

return largestSumInCols > largestSumInRows
? largestSumInCols
: largestSumInRows;
};
``````

2 years ago

I think the tests are not correct...

This is what you should have gotten 184 This is what your code returned 166 Arguments for the failed test case 10,20,30, 0,74,5,7,7,3, 76,90

2 years ago

Read the instructions more carefully...need to sum along columns too... LOL