Guest User

Untitled

a guest
Dec 25th, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import random
  2.  
  3. ALL_HOLES=[(1, 5),
  4.  (2, 3),
  5.  (3, 4),
  6.  (4, 4),
  7.  (5, 5),
  8.  (6, 4),
  9.  (7, 3),
  10.  (8, 4),
  11.  (9, 3),
  12.  (10, 4),
  13.  (11, 3),
  14.  (12, 4),
  15.  (13, 4),
  16.  (14, 3),
  17.  (15, 4),
  18.  (16, 5),
  19.  (17, 4),
  20.  (18, 4)]
  21.  
  22. PAR3_HOLES=[i for i in ALL_HOLES if i[1]==3]
  23. PAR4_HOLES=[i for i in ALL_HOLES if i[1]==4]
  24. PAR5_HOLES=[i for i in ALL_HOLES if i[1]==5]
  25.  
  26. # Must allow at least 2 holes of par 4, and 5
  27. n3 = random.randint( 1, 4 )
  28. SEL_PAR3_HOLES = random.sample( PAR3_HOLES, n3 )
  29.  
  30. # Must allow at least 1 hole of par 5
  31. n4 = random.randint( 1, 5 - n3 )
  32. SEL_PAR4_HOLES = random.sample( PAR4_HOLES, n4 )
  33.  
  34. n5 = 6 - n4 - n3
  35. SEL_PAR5_HOLES = random.sample( PAR5_HOLES, n5 )
  36.  
  37. # Selected values are in SEL_PAR3_HOLES, SEL_PAR4_HOLES, SEL_PAR5_HOLES
  38. print len( SEL_PAR3_HOLES ), len( SEL_PAR4_HOLES ), len( SEL_PAR5_HOLES )
Advertisement
Add Comment
Please, Sign In to add comment