Created
October 16, 2017 04:57
-
-
Save kaibrabo/c5fc442e759c1e7fb469cd4590ae7eb3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(:+) | |
(a_diagonal - b_diagonal).abs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment