From The Sunday Times, 30th August 1964 [link]
I am the Managing Director of a factory and I have under me five employees. Their names are: Alf, Bert, Charlie, Duggie and Ernie. And their jobs are, not necessarily respectively: Doorkeeper, Doorknob Polisher, Bottle Washer, Welfare Officer and Worker.
There has been some dissatisfaction recently about wages which, in the past, I am bound to admit, have sometimes been rather haphazard. It is clearly very difficult to arrange things in such a way that merit is appropriately rewarded, but it seemed to me important that everybody’s position should at least be clear. After much thought, therefore, I put up the following notice:
Wages:
1. Alf is to get more than Duggie.
2. Ernie is to get 12 per cent more than the Bottle Washer will when he receives the 10 percent rise that he will be getting next month.
3. The Doorknob Polisher is to get 30 per cent more than he used to.
4. Charlie is to get £12 a year less than 20 per cent more than the Welfare Officer.
5. No one is to get less than £200 or more than £600 a year.
6. The Doorkeeper is to get 5 per cent more than he would if he got 10 per cent less than Bert.
Everyone always has received in my factory, receives now, and as long as I am in charge will always receive an exact number of £s per year.
What are the various jobs of my employees, and what yearly wage is each of them to get?
This puzzle is included in the book Sunday Times Brain Teasers (1974). The puzzle text above is taken from the book.
[teaser177]
Jim Randell 4:49 pm on 4 November 2022 Permalink |
This Python program runs in 61ms. (Internal runtime is 9.2ms).
Run: [ @replit ]
from enigma import (irange, sq, nsplit, diff, intersect, append, delete, subsets, printf) # model a symmetric relation class Relation(set): # check if x is related to y def __call__(self, x, y): return (x, y) in self or (y, x) in self # names names = "ALAN CARY JAMES LUCY NICK RICKY STEVE VICTOR".split() # names are related when they share a letter N = Relation((x, y) for (x, y) in subsets(names, size=2) if intersect([x, y])) # find 3-digits squares with no repeated digits sqs = dict() for i in irange(10, 31): ds = set(nsplit(sq(i))) if len(ds) == 3: sqs[i] = ds # values are related when their squares share a digit V = Relation((x, y) for ((x, sx), (y, sy)) in subsets(sqs.items(), size=2) if intersect([sx, sy])) # assign values to remaining names # names = remaining names # ss = used (name, value) pairs # vs = remaining values def solve(names, ss, vs): if not names: yield ss elif not len(names) > len(vs): # choose a value for the next name n = names[0] for (i, v) in enumerate(vs): # check values have digits in common when names have letters in common if all(N(n, n_) == V(v, v_) for (n_, v_) in ss): # solve for the remaining names yield from solve(names[1:], append(ss, (n, v)), delete(vs, [i])) # choose an age for LUCY (the youngest) n0 = "LUCY" ks = sorted(sqs.keys()) for (i, k) in enumerate(ks): # solve for the remaining names for ss in solve(diff(names, {n0}), [(n0, k)], ks[i + 1:]): # output solution for (n, v) in sorted(ss): printf("{n} -> {v} [{s}]", s=sq(v)) printf()Solution: The ages are: 19, 31, 29, 16, 25, 23, 28, 27.
With squares in square brackets:
LikeLike
Paul Byrne 9:54 pm on 14 November 2022 Permalink |
Hi Jim
Thanks for all the good work on these Teasers.
Love the simplicity of your website and your solutions.
Re 3137 Teaser
Is 24 instead of 31 also a correct answer? Keep up the good work!
LikeLike
Jim Randell 9:17 am on 15 November 2022 Permalink |
@Paul: Thanks for the feedback.
We can’t swap CARY for 24 in the solution I give above, as 24² = 576, and CARY and JAMES share the letter A, so their squares need to share a digit. But 576 and 841 (= 29²) don’t have any digits in common.
LikeLike
Paul Byrne 10:21 am on 16 November 2022 Permalink |
Hi Jim, thank you very much for your response.
Forgive me I should’ve made myself clearer.
If Cary becomes 576, and James 784, and Steve 841, can it then work as an alternative?
LikeLike
Jim Randell 12:14 pm on 16 November 2022 Permalink |
@Paul: My program performs an exhaustive search, so there is only one solution to the puzzle.
If we had:
Then {LUCY, NICK, RICKY} must correspond to {16 [256], 23 [529], 25 [625]} in some order.
LUCY is the youngest, so we have:
But then ALAN has to have digits in common with CARY [576], LUCY [256], JAMES [784], but not STEVE [841]
Which means for ALAN we need to find a square with a 7 and a 5 or a 6. The only candidate is 24 [576], but that is already used by CARY, so it is not possible to find a value for ALAN in this scenario.
LikeLike
Paul Byrne 5:17 pm on 16 November 2022 Permalink |
Hi Jim
Alas I’m thwarted!
Thanks for this and all your efforts.
They are all appreciated.
Regards Paul
LikeLike