-
-
Save kaibrabo/941fd333b0796f0075e0a92fc279996d 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
n = gets.strip.to_i | |
a = Array.new(n) | |
for a_i in (0..n-1) | |
a_t = gets.strip | |
a[a_i] = a_t.split(' ').map(&:to_i) | |
arr = a[a_i] | |
end | |
a_diagonal = (0...arr.length).collect { |h| | |
a[h][h] | |
}.reduce(:+) | |
rev_a = a.each { |i| | |
i.reverse! | |
} | |
b_diagonal = (0...arr.length).collect { |i| | |
rev_a[i][i] | |
}.reduce(:+) | |
p (a_diagonal - b_diagonal).abs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment