Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let isMagic = true;
- let sum = input[0].reduce((a, b) => a + b,0);
- for(let i = 0; i < input[0].length; i ++) {
- if(sum !== input[i].reduce((a, b) => a + b, 0)){
- isMagic = false;
- break;
- }
- if(isMagic){
- let current = 0;
- for(let j = 0; j < input.length; j ++) {
- current += input[i][j];
- }
- if(sum !== current){
- isMagic = false;
- break;
- }
- } else {
- break;
- }
- }
- console.log(isMagic);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement