Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- ALL_HOLES=[(1, 5),
- (2, 3),
- (3, 4),
- (4, 4),
- (5, 5),
- (6, 4),
- (7, 3),
- (8, 4),
- (9, 3),
- (10, 4),
- (11, 3),
- (12, 4),
- (13, 4),
- (14, 3),
- (15, 4),
- (16, 5),
- (17, 4),
- (18, 4)]
- PAR3_HOLES=[i for i in ALL_HOLES if i[1]==3]
- PAR4_HOLES=[i for i in ALL_HOLES if i[1]==4]
- PAR5_HOLES=[i for i in ALL_HOLES if i[1]==5]
- # Must allow at least 2 holes of par 4, and 5
- n3 = random.randint( 1, 4 )
- SEL_PAR3_HOLES = random.sample( PAR3_HOLES, n3 )
- # Must allow at least 1 hole of par 5
- n4 = random.randint( 1, 5 - n3 )
- SEL_PAR4_HOLES = random.sample( PAR4_HOLES, n4 )
- n5 = 6 - n4 - n3
- SEL_PAR5_HOLES = random.sample( PAR5_HOLES, n5 )
- # Selected values are in SEL_PAR3_HOLES, SEL_PAR4_HOLES, SEL_PAR5_HOLES
- print len( SEL_PAR3_HOLES ), len( SEL_PAR4_HOLES ), len( SEL_PAR5_HOLES )
Advertisement
Add Comment
Please, Sign In to add comment