Re: [BangPypers] golf problem

2011-12-28 Thread Kenneth Gonsalves
On Wed, 2011-12-28 at 06:44 +0530, Kenneth Gonsalves wrote: > 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 checkli

Re: [BangPypers] golf problem

2011-12-27 Thread Kenneth Gonsalves
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 fashione

Re: [BangPypers] golf problem

2011-12-27 Thread Kenneth Gonsalves
On Tue, 2011-12-27 at 18:19 +0530, Pratap Chakravarthy wrote: > I have posted at, http://pastebin.com/BG6X70Sv > I don't understand why or how it got stripped. mailing list policy -- regards Kenneth Gonsalves ___ BangPypers mailing list BangPypers@pyt

Re: [BangPypers] golf problem

2011-12-27 Thread Pratap Chakravarthy
I have posted at, http://pastebin.com/BG6X70Sv I don't understand why or how it got stripped. Cheers, On Tue, Dec 27, 2011 at 11:26 AM, Kenneth Gonsalves wrote: > On Mon, 2011-12-26 at 17:34 +0530, Pratap Chakravarthy wrote: >> Attached is the file. > > I think the attachment got stripped. > --

Re: [BangPypers] golf problem

2011-12-26 Thread Kenneth Gonsalves
On Mon, 2011-12-26 at 17:34 +0530, Pratap Chakravarthy wrote: > Attached is the file. I think the attachment got stripped. -- regards Kenneth Gonsalves ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpyper

Re: [BangPypers] golf problem

2011-12-26 Thread Pratap Chakravarthy
> 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. Attempted to solve the same problem using Erlang, and surprisingly what was looking li

Re: [BangPypers] golf problem

2011-12-26 Thread Noufal Ibrahim
Kenneth Gonsalves writes: [...] > just curious - why do you and Noufal think this is a crude method? I don't like special casing stuff and the 3 selections outside the "main" flow sticks out in my solution. -- ~noufal http://nibrahim.net.in Parting is such sweet sorrow. -William Shakespear

Re: [BangPypers] golf problem

2011-12-26 Thread Kenneth Gonsalves
On Mon, 2011-12-26 at 10:01 +0530, Pratap Chakravarthy wrote: > # Initialize variables > holes, bk = HOLES[:], {} ; > random.shuffle( holes ) > > # Make buckets > [ bk.setdefault(y, []).append((x,y)) for x, y in holes ] > > # Result > print [ bk[3].pop(0), bk[4].pop(0), bk[5].pop(0) ] + random.

Re: [BangPypers] golf problem

2011-12-25 Thread Gaurav Kalra
From: steve > I am sorry, I didn't quite understand this bit "it is necessary to generate a > random list of 6 holes.", since the list below has 18 elements. That means out of the 18 elements from the list, we need 6 random elements but with one constraint. > In any case, whether you need 6 or

Re: [BangPypers] golf problem

2011-12-25 Thread Kenneth Gonsalves
On Mon, 2011-12-26 at 10:01 +0530, Pratap Chakravarthy wrote: > # Initialize variables > holes, bk = HOLES[:], {} ; > random.shuffle( holes ) > > # Make buckets > [ bk.setdefault(y, []).append((x,y)) for x, y in holes ] > > # Result > print [ bk[3].pop(0), bk[4].pop(0), bk[5].pop(0) ] + random.

Re: [BangPypers] golf problem

2011-12-25 Thread Kenneth Gonsalves
On Mon, 2011-12-26 at 10:01 +0530, Pratap Chakravarthy wrote: > # Initialize variables > holes, bk = HOLES[:], {} ; > random.shuffle( holes ) > > # Make buckets > [ bk.setdefault(y, []).append((x,y)) for x, y in holes ] > > # Result > print [ bk[3].pop(0), bk[4].pop(0), bk[5].pop(0) ] + random.

Re: [BangPypers] golf problem

2011-12-25 Thread Pratap Chakravarthy
# Initialize variables holes, bk = HOLES[:], {} ; random.shuffle( holes ) # Make buckets [ bk.setdefault(y, []).append((x,y)) for x, y in holes ] # Result print [ bk[3].pop(0), bk[4].pop(0), bk[5].pop(0) ] + random.sample( bk[3] + bk[4] + bk[5], 3 ) Some times the crude method is the best meth

Re: [BangPypers] golf problem

2011-12-25 Thread steve
Hi, On 12/25/2011 12:52 PM, Kenneth Gonsalves wrote: > hi, > > a golf course has 18 holes. There are three types of hole - par 3, par 4 > and par 5. For a certain type of tournament it is necessary to generate > a random list of 6 holes. The only condition is that this list should > contain at le

Re: [BangPypers] golf problem

2011-12-25 Thread Baishampayan Ghose
> a golf course has 18 holes. There are three types of hole - par 3, par 4 > and par 5. For a certain type of tournament it is necessary to generate > a random list of 6 holes. The only condition is that this list should > contain at least one of each type of hole. What would be an elegant way > of

Re: [BangPypers] golf problem

2011-12-25 Thread Noufal Ibrahim
Kenneth Gonsalves writes: > hi, > > a golf course has 18 holes. There are three types of hole - par 3, par 4 > and par 5. For a certain type of tournament it is necessary to generate > a random list of 6 holes. The only condition is that this list should > contain at least one of each type of hol

Re: [BangPypers] golf problem

2011-12-25 Thread Gora Mohanty
On Sun, Dec 25, 2011 at 12:52 PM, Kenneth Gonsalves wrote: > hi, > > a golf course has 18 holes. There are three types of hole - par 3, par 4 > and par 5. For a certain type of tournament it is necessary to generate > a random list of 6 holes. The only condition is that this list should > contain

[BangPypers] golf problem

2011-12-24 Thread Kenneth Gonsalves
hi, a golf course has 18 holes. There are three types of hole - par 3, par 4 and par 5. For a certain type of tournament it is necessary to generate a random list of 6 holes. The only condition is that this list should contain at least one of each type of hole. What would be an elegant way of doin