# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1622: Chances for a business meeting

From New Scientist #2787, 20th November 2010 [link]

Jack will enter the office today at a random time between 2pm and 3pm. He will stay in the office for 15 minutes. John has a similar schedule, with the entry time chosen independently.

They have a business to transact and it requires that they are together in the office for 5 minutes before 3pm.

What are the chances that the business is transacted today?

[enigma1622]

### 2 responses to “Enigma 1622: Chances for a business meeting”

1. jimrandell 20 December 2011 at 11:07 pm

This doesn’t require any programming. By drawing a graph we can determine that the time when it is possible to have a successful meeting is when 0 < x < 55/60, 0 < y < 55/60, |x-y| < 10/60, which is the diagonal hexagonal area in the graph.

This has area (55/60)² – 2 × 1/2 x 45/60 × 45/60 (the area of the whole square less the two triangles on the NW and SE corners).

Solution: The chances of business being transacted today is 5/18.

• jimrandell 20 December 2011 at 11:22 pm

The following code runs a simulation of the problem. It runs a million random trials by default (in around 780ms) and gets an answer of around 0.278, close to the expected answer of 0.2777…

```import sys

N = eval(sys.argv[1]) if len(sys.argv) > 1 else 1e6

from itertools import count
from random import random

m55 = 55.0 / 60.0
m10 = 10.0 / 60.0

s = 0 # number of successes
for n in count(1):

j1 = random()
j2 = random()

if j1 < j2:
if j2 < m55 and j2 < j1 + m10:
s += 1
else:
if j1 < m55 and j1 < j2 + m10:
s += 1

if n == N:
print("{f} [{s}/{n}]".format(f = float(s) / float(n), s=s, n=n))
break
```

This site uses Akismet to reduce spam. Learn how your comment data is processed.