import itertools

def interseccions1(it):
    r1 = next(it)
    for r2 in it:
        x = r1 & r2
        if x.color == 'negre':
            yield x.amplada() * x.alçada()
        r1 = r2
        
def interseccions2(it):
    it2 = itertools.pairwise(it)
    it3 = map(lambda t: t[0] & t[1], it2)
    it4 = filter(lambda x: x.color == 'negre', it3)
    it5 = map(lambda x: x.amplada() * x.alçada(), it4)
    return it5

def interseccions3(it):
    it2 = itertools.pairwise(it)
    it3 = map(lambda t: t[0] & t[1], it2)
    it4 = map(lambda x: x.amplada() * x.alçada(), it3)
    it5 = filter(lambda x: x>0, it4)
    return it5

# Escull la solució que vols provar
interseccions = interseccions1

