Teaser 2465 : [Christmas bonus]
From The Sunday Times, 20th December 2009 [link]
Pat’s company employs six staff: they joined on six consecutive Christmases and have stayed ever since. This Christmas, he is giving them each a bonus in the form of vouchers, each worth a whole number of pounds, with one red voucher for each year of service for a man and one green voucher (worth £1 more) for each year of service for a woman. The value of all the year’s vouchers is £500. Ms Jones joined more than two years after Mr Smith, but their bonuses have the same total value.
What is that common value?
This puzzle was originally published with no title.
[teaser2465]







Jim Randell 11:20 am on 26 December 2025 Permalink |
This Python program runs in 70ms. (Internal runtime is 1.7ms).
from enigma import (irange, inf, subsets, div, printf) # choose male (= 0) and female (= 1) values (longest serving -> shortest serving) for vs in subsets([0, 1], size=6, select='M'): # find possible (i, j) values for Mr S and Ms J ijs = list((i, j) for (i, j) in subsets(irange(6), size=2) if j >= i + 3 and vs[i] == 0 and vs[j] == 1) if not ijs: continue # consider increasing values for the male voucher for x in irange(1, inf): # calculate the years of service for the longest serving employee (>= 6) n = 500 + sum(i * (x + v) for (i, v) in enumerate(vs)) d = 6 * x + sum(vs) if n < 6 * d: break y = div(n, d) if y is None: continue # calculate actual gift amounts gs = list((y - i) * (x + v) for (i, v) in enumerate(vs)) # find shared values for Mr S and Ms J for (i, j) in ijs: if gs[i] == gs[j]: # output solution printf("vs={vs}, y={y}, x={x}, gs={gs}, i={i}, j={j}")Solution: The common value is £80.
The red vouchers (male) are worth £4 each. The green vouchers (female) are worth £5 each.
The amounts given to the employees are:
LikeLike
Ruud 1:17 pm on 26 December 2025 Permalink |
Extreme brute force:
import peek import itertools import istr for n in range(1, 30): for bonus in range(100): for is_womans in itertools.product((False, True), repeat=6): if sum(k * (bonus + is_woman) for k, is_woman in enumerate(is_womans, n)) == 500: for jones, smith in itertools.product(range(6), repeat=2): if not is_womans[jones] and is_womans[smith] and jones > smith + 2 and (jones + n) * bonus == (smith + n) * (bonus + 1): peek((jones + n) * bonus, (smith + n) * (bonus + 1))LikeLike