[BangPypers] golf problem

Kenneth Gonsalves lawgon at gmail.com
Wed Dec 28 02:14:47 CET 2011


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



More information about the BangPypers mailing list