On Mon, 2011-12-26 at 17:34 +0530, Pratap Chakravarthy wrote: > > I don't like special casing stuff and the 3 selections outside the> > "main" flow sticks out in my solution. > I guess that is right. Any logic that is outside the main flow breaks > the beauty > and create kludge.
the old fashioned way: def peoria(holes): import random random.shuffle(holes) result = [] checklist = [] used = [] for hole in holes: if len(checklist) == 3: break if hole[1] not in checklist: result.append(hole) checklist.append(hole[1]) used.append(hole) available = set(holes) - set(used) result.extend(list(available)[:3]) return result -- regards Kenneth Gonsalves _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers