You are viewing a single comment's thread. Return to all comments →
Python3 short but horrible:
adj = ((0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)) def detonate(grid, t, i, j): return any(t - grid[i + x][j + y] == 3 for x, y in adj if i + x >= 0 and j + y >= 0 and i + x < len(grid) and j + y < len(grid[0])) def bomberMan(n, grid): n = min(n, 2 + (n-2) % 4) grid = [[('.', 0)[c == 'O'] for c in r] for r in grid] for t in range(2, n+1, 2): grid = [[t if c == '.' else c for c in r] for r in grid] if t+1 <= n: grid = [['.' if detonate(grid, t+1, i, j) else grid[i][j] for j in range(len(grid[i]))] for i in range(len(grid))] return [''.join(('O', '.')[c == '.'] for c in r) for r in grid]
Seems like cookies are disabled on this browser, please enable them to open this website
The Bomberman Game
You are viewing a single comment's thread. Return to all comments →
Python3 short but horrible: