The Bomberman Game

  • + 0 comments
    def bomberMan(n, g):
        x = lambda g: g if n < 2 else ['O' * len(g[0]) for _ in g] if n % 2 == 0 else [''.join(['.' if g[y][x] == 'O' or (g[y][x] == '.' and 'O' in (g[max(y-1, 0)][x], g[y][max(x-1, 0)], g[y][min(x+1, len(g[0])-1)], g[min(y+1, len(g)-1)][x])) else '.' if g[y][x] == 'O' else 'O' for x in range(len(g[0]))]) for y in range(len(g))]
        return x(g) if n % 4 == 3 else x(x(g))