# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1151: Workers’ bonus

From New Scientist #2307, 8th September 2001 [link]

Each of the workers of the Manufacturing Company joined the company on 30 June in some year before 1996. The company’s profits for each year ending 30 June are always the same, £P, where P is a whole number between 2000 and 2500. On the 30 June each year, each worker, W, receives a bonus of P × (A/B) pounds, rounded, if necessary, to the nearest pound, with 50p going up; where A = the number of years W has worked for the company, and B = the sum of the numbers of years worked for the company by all the workers. Worker Frances found that in each of the years 1996, 1997 and 1998 her figure P × (A/B) was a whole number and she received bonuses of £315, £336 and £350, respectively.

Question 1. What is P?

Frances joined the company at least one year later than every other worker. Suppose that all the workers live for 1000 years and over that 1000 years the company’s annual profits remain at £P and no worker joins or leaves the company.

Question 2. What is the first year when all the workers will receive the same bonus?

[enigma1151]

### 2 responses to “Enigma 1151: Workers’ bonus”

1. Jim Randell 5 September 2016 at 9:21 am

This Python program runs in 52ms.

```from itertools import count
from enigma import irange, intf, intc, printf

# return a / b rounded to the nearest integer
def round(a, b):
(n, r) = divmod(a, b)
return (n if 2 * r < b else n + 1)

# consider values for P
# (total profits)
for P in irange(2000, 2500):

# consider values for A
# (number of years Frances has worked for the company in 1996)
for A in irange(1, 60):

# from the 1996 bonus the value of B is...
# (B = numbers of years worked by all workers in 1996)
(B, r) = divmod(P * A, 315)
if r > 0: continue

# assuming no-one joins or leaves the company
# use the 1997 bonus to calculate N
# (N = number of workers in the company)
(BN, r) = divmod(P * (A + 1), 336)
if r > 0: continue
N = BN - B
if not(N > 0): continue

# and check the 1998 bonus
if 350 * (B + 2 * N) != P * (A + 2): continue

printf("(1) P={P} [A={A} B={B} N={N}]")

# calculate Amin, Amax
# (Amin = smallest possible number of years worked by another worker)
# (Amax = largest possible number of years worked by another worker)
Amin = A + 1
Amax = B - A - (N - 2) * Amin
if Amax < Amin: continue
printf("Amin = {Amin}, Amax = {Amax}")

# now look for the first year when the bonus for Frances
# and the bonus for Amax are the same
for i in irange(0, 1000):
BF = round(P * (A + i), B + N * i)
Bmax = round(P * (Amax + i), B + N * i)
if BF == Bmax:
printf("(2) year={y} [BF={BF} Bmax={Bmax}]", y=1996 + i)
break
```

Solution: (1) P = £2100. (2) All workers will receive the same bonus in the year 2833.

Frances has worked for the company for 3 years in 1996 (so she joined in 1993), and there are 4 other workers who have worked 17 years between them. (Making a total workforce of 5 with 20 years experience when Frances is included).

For the second part of the problem the program finds the maximum possible bonus based on a worker who has worked for the maximum possible amount of time. This happens when all the remaining workers joined the company one year before Frances, and the “old-hand” has worked the remaining years.

As it turns out there are 4 workers with 17 years experience between them, and each must have at least 4 years experience (as Frances has 3), so the only possible distribution is 3 workers with 4 years experience and 1 worker with 5 years experience. So the maximum is achieved. In 2833 each worker would receive a bonus of £420.

Instead of looking at the bonuses for the next 1000 years we can get an estimate of when it will occur by dividing the profit amongst the workers.

bonus = £2100 / 5 = £420

and then use this to find an approximation for year, by solving the equation for Frances’ bonus:

£2100 × (3 + n) / (20 + 5 × n) = £419.5
⇒ n = 836

So we should check years around 1996 + 836 = 2832.

2. Hugh Casement 5 September 2016 at 10:26 am

What a very silly puzzle, at least as far as the wording goes.  Is it usual for a company to give out all its profits in bonuses for the workers?  Better would be to say that it always sets aside £P for that, each worker to receive £P/B for each year of service, where B is the sum of the years worked by all.  And then to ask whether all will receive the same amount in the foreseeable future: nobody stays 800 years with the same company!