On Jun 15, 2:37 pm, Peter Otten <__pete...@web.de> wrote: > >>> from itertools import cycle, izip > >>> sum(sign*i*i for sign, i in izip(cycle([1]*3+[-1]*2), range(1, 2011)))
Wow!! :D I didn't knew cycle, great! With that i can reduce my solution (which isn't still elegant as your) to: print reduce(add,imap(mul, cycle([1, 1, 1, -1, -1]), (v**2 for v in xrange(1, 2011)))) (536926141) ~Aki -- http://mail.python.org/mailman/listinfo/python-list