the real answer for problem 6
p7 is solved, but not elegant, see this link:
http://garethrees.org/2007/05/07/python-challenge/