Created
November 12, 2017 22:18
-
-
Save ldco2016/a8e2c10cf510f2fb34e277e6efd3ea96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
var n = parseInt(readLine()); | |
var a = []; | |
for(a_i = 0; a_i < n; a_i++){ | |
a[a_i] = readLine().split(' '); | |
a[a_i] = a[a_i].map(Number); | |
} | |
let sumPrimaryDiagonal = sumSecondaryDiagonal = 0; | |
for (i = 0, len = a.length; i < len; i++) { | |
let line = a[i]; | |
sumPrimaryDiagonal += line[i]; | |
sumSecondaryDiagonal += line[(len -1) - i]; | |
} | |
console.log(Math.abs(sumPrimaryDiagonal - sumSecondaryDiagonal)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment