#Cynthia Liu
#Montgomery Blair
HS
#3029
#Junior 5
Division
#Contest 3
for i in range(1,
6):
row, column, n = input("Please input
the queen's row and column number, and its maximum range (separated by commas):
")
r, c, d = 0, 0, 0 #these variables are the number of
unsafe squares in the queen's row, column, or diagonal, not including the queen
herself
#unsafe squares in row:
if (column + n) > 5: #right
r += 5 - column
else:
r += n
if (column - n) < 1: #left
r += column - 1
else:
r += n
#unsafe squares in column
if (row + n) > 5: #up
c += 5 - row
else:
c += n
if (row - n) < 1: #down
c += row - 1
else:
c += n
#unsafe squares in diagonals
for k in range(1, n+1):
if (row + k) <= 5 and (column + k)
<= 5: #upper right
d += 1
if (row - k) >= 1 and (column + k)
<= 5: #lower right
d += 1
if (row + k) <= 5 and (column - k)
>= 1: #upper left
d += 1
if (row - k) >= 1 and (column - k)
>= 1: #lower left
d += 1
k += 1
safesquares = 25 - (r+c+d + 1) #the queen's
space can't be occupied!
print
(str(safesquares) + "\n")
i+=1