Dangerous Bishops

Dangerous Bishops

The generalized square chessboard has been taken over by an army of bishops, each bishop represented as a two-tuple (row, col) (0-base indexing) of the coordinates of the square that the bishop stands on. Given the board size n and the list of bishops on that board, count the number of safe squares that are not covered by any bishop.

Let's look at the case 4, [(2, 3), (0, 1)], which is 11.

example

Input: Two arguments. Integer (int) and list of tuples of two integers.

Output: Integer.

Examples:

assert safe_squares(10, []) == 100
assert safe_squares(4, [(2, 3), (0, 1)]) == 11
assert safe_squares(8, [(1, 1), (3, 5), (7, 0), (7, 6)]) == 29

The mission was taken from Python CCPS 109. It is taught for Ryerson Chang School of Continuing Education by Ilkka Kokkarinen