# 80->100 length

Sep 24th, 2020
916
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function solve(input) {
2.
3.   // judge: 80 / 100 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4.
5.   let isMagical = false;
6.   let sumArrCells = [];
7.   let sumArrColumns = [];
8.
9.   let len = input.length
10.
11.   for (let i = 0; i < len; i++) {
12.     let currentArr = input[i];
13.     let sumCells = 0;
14.     for (let j = 0; j < len; j++) {
15.       let currentElement = currentArr[j];
16.       sumCells += currentElement;
17.     }
18.     sumArrCells.push(sumCells);
19.   }
20.
21.   for (let i = 0; i < len; i++) {
22.     let sumColumns = 0;
23.     for (let j = 0; j < len; j++) {
24.       let current = input[j][i]
25.       sumColumns += current;
26.     }
27.     sumArrColumns.push(sumColumns);
28.   }
29.
30.   for (let i = 0; i < len; i++) {
31.     if (sumArrCells[i] == sumArrCells[i + 1]) {
32.       isMagical = true;
33.     }
34.   }
35.
36.   for (let i = 0; i < len; i++) {
37.     if (sumArrColumns[i] == sumArrColumns[i + 1]) {
38.       isMagical = true;
39.     }
40.   }
41.   console.log(isMagical);
42. }