Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import collections
- days = {'monday', 'tuesday', 'wednesday', 'thursday',
- 'friday', 'saturday', 'sunday'}
- events = {'A', 'B', 'C'}
- def flip():
- answers = dict()
- for a_day in days:
- answers[a_day] = dict()
- for an_event in events:
- answers[a_day][an_event] = False
- for a_day in random.sample(days, 3):
- answers[a_day]['A'] = True
- for a_day in random.sample(days, 4):
- answers[a_day]['B'] = True
- for a_day in random.sample(days, 2):
- answers[a_day]['C'] = True
- multiple_days = 0
- for a_day in days:
- if collections.Counter(answers[a_day].values())[True] > 1:
- multiple_days = multiple_days + 1
- return multiple_days
- def test():
- multiple_days = 0
- for x in range(1, 100000):
- v = flip()
- multiple_days = v + multiple_days
- print(multiple_days / (7.0 * 100000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement