Chess coins (2) X89253


Statement
 

pdf   zip

thehtml

Consider a square chess board with n rows and n columns, where every square contains a number of coins. Write a program such that, given a chess board, computes the total number of coins on the diagonals. The first square in the board (top left) is always white.

Input

The input is a natural number n>0, followed by n rows, each with n non-negative integers, separated by whitespaces.

Output

The ouput is the total number of coins in the board diagonals.

Public test cases
  • Input

    8
    0 1 0 1 0 1 0 0
    1 0 1 0 1 0 0 0
    0 1 0 1 0 0 0 1
    1 0 1 0 0 0 1 0
    0 1 0 0 0 1 0 1
    1 0 0 0 1 0 1 0
    0 0 0 1 0 1 0 1
    0 0 1 0 1 0 1 0

    Output

    0
    
  • Input

    6
    2 0 0 0 0 1
    0 2 0 0 1 0
    0 0 2 1 0 0
    0 0 1 2 0 0
    0 1 0 0 2 0
    1 0 0 0 0 2

    Output

    18
    
  • Input

    5
     2 38 91 10  0
    21  4 12  9 14
     3  6 77 22 21
    20  4 18  6  3
     5 61  7  2 19
    

    Output

    126
    
  • Information
    Author
    Lluís Padró
    Language
    English
    Official solutions
    Python
    User solutions
    Python