Рая обнови решението на 30.03.2012 22:33 (преди над 12 години)
+def step_board(board):
+ new_board = create_board()
+ for row in range(1, BOARD_SIZE + 1):
+ for column in range(1, BOARD_SIZE + 1):
+ new_board[row][column] = 0
+ alive_neighbours = 0
+ for r in [row - 1, row, row + 1]:
+ for c in [column - 1, column, column + 1]:
+ if board[r][c] == 1:
+ alive_neighbours += 1
+ if board[row][column] == 1:
+ alive_neighbours -= 1
+ if alive_neighbours == 2 or alive_neighbours == 3:
+ new_board[row][column] = 1
+ elif board[row][column] == 0:
+ if alive_neighbours == 3:
+ new_board[row][column] = 1
+ for row in range(1, BOARD_SIZE + 1):
+ for column in range(1, BOARD_SIZE + 1):
+ board[row][column] = new_board[row][column]