Skip to content

Instantly share code, notes, and snippets.

@timkofu
Last active December 22, 2016 11:50
Show Gist options
  • Save timkofu/cb4b404b1510b5f32aa7d892e3c0eaa6 to your computer and use it in GitHub Desktop.
Save timkofu/cb4b404b1510b5f32aa7d892e3c0eaa6 to your computer and use it in GitHub Desktop.
just coz
# Given a square matrix of size N x N, calculate the absolute difference between the sums of its diagonals.
m_raw = input().strip()
m_order = int(m_raw.split("\n")[0])
for _ in range(m_order):
m_raw += "\n"+input().strip()
m_trix = [list(map(int, x.strip().split())) for x in m_raw.split("\n")][1:]
print(abs(sum([(m_trix[x][x] - m_trix[x][-(x+1)]) for x in range(m_order)])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment