SHARE
TWEET

Untitled

a guest Jan 23rd, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr){
  2.  
  3. let verticalArray = []
  4. let horizontalArray = []
  5. let flag = true
  6. let step = 0
  7.  
  8.  
  9. for(let i = 0; i < arr.length; i++){
  10.  
  11.     let currentHorizontal = arr[i].reduce((a,b) => a+b, 0)
  12.  
  13.     horizontalArray.push(currentHorizontal)
  14.  
  15.     for(let element of arr){
  16.        verticalArray[step] = element[i]
  17.        step++
  18.     }
  19.     verticalArray[i] = verticalArray.reduce((a, b) => a+b, 0)
  20.     if(horizontalArray[i] === verticalArray[i]){
  21.         flag = true
  22.     }else{
  23.         flag = false
  24.         break
  25.     }
  26.    verticalArray = []
  27. }
  28.  
  29. console.log(flag);
  30.  
  31.  
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top