Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function magicMatrices(matrix) {
- for (let i = 0; i < matrix.length - 1; i++) {
- let sumROne = matrix[i].reduce((a, b) => a + b, 0);
- let sumRTwo = matrix[i + 1].reduce((a, b) => a + b, 0);
- let sumCOne = 0;
- let sumCTwo = 0;
- for (let j = 0; j < matrix.length; j++) {
- sumCOne += matrix[i][j];
- sumCTwo += matrix[i + 1][j];
- }
- if (sumROne !== sumRTwo || sumCOne !== sumCTwo) {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement