import itertools

def iter_tots1(p):
    it1 = map(lambda n: p[:n]+p, range(len(p)+1))
    it2 = filter(lambda p: 'rrr' not in p and 'sss' not in p and 'lll' not in p, it1)
    return it2

def iter_tots2(p):
    it1 = itertools.accumulate(p, initial='')
    it2 = map(lambda s: s+p, it1)
    it3 = filter(lambda p: 'rrr' not in p and 'sss' not in p and 'lll' not in p, it2)
    return it3

# tria la solució que vols provar
iter_tots = iter_tots1
