[BangPypers] golf problem

Noufal Ibrahim noufal at gmail.com
Sun Dec 25 09:36:58 CET 2011

Kenneth Gonsalves <lawgon at gmail.com> 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 hole. What would be an elegant way
> of doing this. Sample data for Ooty golf course is given below. The hole
> number is the first element of each tuple and the par is the second
> element.

I can think of a crude way. 

Keep a list of buckets (par 3, par 4 and par 5). Select one random hole
from each bucket. Now your constraint is satisfied. Then just select 3
more from the whole set of holes (minus the three already selected) to
get the total upto 6.



I disagree with unanimity.

More information about the BangPypers mailing list