You are viewing a single comment's thread. Return to all comments →
Came to the same result, but ruby way. Just one loop
diag1=diag2=0 for i in (0...n) diag1 += a[i][i] diag2 += a[i][n-i-1] end puts (diag1-diag2).abs
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
Came to the same result, but ruby way. Just one loop