Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import collections
  2.  
  3. days = {'monday', 'tuesday', 'wednesday', 'thursday',
  4.         'friday', 'saturday', 'sunday'}
  5. events = {'A', 'B', 'C'}
  6.  
  7. def flip():
  8.     answers = dict()
  9.     for a_day in days:
  10.         answers[a_day] = dict()
  11.         for an_event in events:
  12.             answers[a_day][an_event] = False
  13.  
  14.     for a_day in random.sample(days, 3):
  15.         answers[a_day]['A'] = True
  16.  
  17.     for a_day in random.sample(days, 4):
  18.         answers[a_day]['B'] = True
  19.  
  20.     for a_day in random.sample(days, 2):
  21.         answers[a_day]['C'] = True
  22.  
  23.     multiple_days = 0
  24.     for a_day in days:
  25.         if collections.Counter(answers[a_day].values())[True] > 1:
  26.             multiple_days = multiple_days + 1
  27.     return multiple_days
  28.  
  29.  
  30. def test():
  31.     multiple_days = 0
  32.     for x in range(1, 100000):
  33.         v = flip()
  34.         multiple_days = v + multiple_days
  35.     print(multiple_days / (7.0 * 100000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement