Димитър обнови решението на 26.03.2012 16:56 (преди почти 13 години)
+def step_board(board):
+ def living_force(board, row, col):
+ edge = [0, BOARD_SIZE + 1]
+ if row in edge or col in edge:
+ return 0
+
+ square = [_, __ for ]
+ neighbours = [board[_][__]
+ for _ in range(row - 1,row + 2)
+ for __ in range(col - 1, col + 2)]
+ res = sum(neighbours) - board[row][col]
+
+ return res
+
+ new_board = [[1 if (board[i][j] and living_force(board, i, j) in
+[2,3]) or
+ not board[i][j] and living_force(board, i, j) == 3
+else 0
+ for j in range(len(board[i]))]
+ for i in range(len(board))]
+
+ for row in range(len(board)):
+ board[row] = new_board[row][:]