def gen(x):
    if not x:
        yield 0
return
for i in range(len(x)):
    for a in gen(x[i + 1:]):
        yield a + x[0]
print('Round 1')
for a in gen([2, 3, 4, 5]):
    print(a)
print() 
print('Round 2')
for a in gen([2, 3, 4, 5]):
    pass
Can I memoize a Python generator?