• + 0 comments

    def twoPluses(grid):

    pl = []
    result = 0
    for i,j in product(range(len(grid)), range(len(grid[0]))):
        if grid[i][j] == 'G':
            pl2 = set()
            for k in range(0, len(grid)//2+1):
                if j-k<0 or j+k>len(grid[0])-1 or i-k<0 or i+k>len(grid)-1:
                    break
                if grid[i][j-k] == grid[i][j+k] == grid[i-k][j] == grid[i+k][j] == 'G':
                    pl2.update(((i,j-k),(i,j+k,),(i-k,j),(i+k,j)))
                    pl.append(pl2.copy())
                else:
                    break
    for i in combinations(pl, 2):
        if not i[0] & i[1]:
            result = max(result, len(i[0])*len(i[1]))
    
    return result