Chess coins (1) X78444


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 difference between the total number of coins on white squares and the total number of coins on black squares. 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 output is the total number of coins in white squares, and the total number of coins in white squares. Follow the format of the examples.

Public test cases
  • Input

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

    Output

    white: 0, black: 32
    
  • Input

    6
    2 0 2 0 2 0
    0 2 0 2 0 2
    2 0 2 0 2 0
    0 2 0 2 0 2
    2 0 2 0 2 0
    0 2 0 2 0 2
    

    Output

    white: 36, black: 0
    
  • Input

    4
     2 38 91 10
    21  4 12  9
     3  6 77 22
    20  4 18  6

    Output

    white: 196, black: 147
    
  • Information
    Author
    Lluís Padró
    Language
    English
    Official solutions
    Python
    User solutions
    Python