Python for Set 1 (so much faster to implement than C\!)