row = 4 # stroka
col = 4 # stolbec
grid = ((1, 0, 0, 1, 0),
(0, 1, 0, 0, 0),
(0, 0, 1, 0, 1),
(1, 0, 0, 1, 0),
(0, 0, 1, 0, 0))
asd = []
n = -1
while n < 2:
if n == -1 or n == 1:
asd.append(grid[row+n][col+n]) # main diagonal
asd.append(grid[row][col+n]) # horizon
asd.append(grid[row+n][col]) # vertical
asd.append(grid[row+n][col-n]) # secondary diagonal
n += 1
print(asd.count(1))
Created at: 2016/03/04 22:58; Updated at: 2016/03/05 11:14