On a random day, Daniel arrives at his favorite coffee shop between 12:00 and 13:00, stays some time, and leaves. Elliot does exactly the same. The following code generates the minutes after 12:00 of their arrival and departure:
def daniel():
arrival = random.randrange(60)
departure = arrival + random.randrange(10, 25)
return arrival, departure
def elliot():
arrival = random.randrange(60)
departure = arrival + random.randrange(5, 15)
return arrival, departure
Using 10,000 repetitions, estimate the probability that Daniel and Eliot will meet at a coffee shop. In a situation where one of them left and at the same time another came in, we will assume that they met.