Teaser 3097: Crazy golf
From The Sunday Times, 30th January 2022 [link] [link]
Ian was trying to entertain John and Ken, his 2 young nephews, in the local park, which had a 9-hole crazy golf course. He decided to play a round with each of them separately, and gave them money for each hole he lost on a rising scale. He would pay £1 if he lost the first hole (or the first hole after winning one), then £2 if he lost the next consecutive hole, and £3 for the third, and so on.
In the event, Ian won only 5 holes in total between the two rounds, including the first hole against John and the last hole against Ken. There were no ties. At the reckoning after both rounds, both boys received equal amounts of money.
How much did it cost Uncle Ian?
[teaser3097]







Jim Randell 4:47 pm on 28 January 2022 Permalink |
Each boy loses a hole at one end of the course, so we can just consider course with 8 holes, as we are only interested in groups of consecutive wins.
This Python program runs in 47ms.
Run: [ @replit ]
from enigma import (irange, subsets, intersect, printf) # consider a course with 8 holes holes = irange(1, 8) # calculate the winnings for a nephew who wins holes <ws> def winnings(ws): (t, h) = (0, 0) for n in holes: if n in ws: h += 1 t += h else: h = 0 return t # choose 5 to 8 extra holes for J and K X = dict() for n in irange(5, 8): X[n] = set(winnings(ws) for ws in subsets(holes, size=n)) # consider number of holes won by J for j in irange(5, 8): k = 13 - j # look for equal amounts for w in intersect([X[j], X[k]]): printf("I pays {t} [J wins {j}; K wins {k}]", t=w + w)Solution: Ian paid £32 to the boys.
Ian lost to one of the boys on 5 consecutive holes and 1 other, paying (1 + 2 + 3 + 4 + 5) + 1 = £16.
And to the other boy on 4 consecutive holes and another 3 consecutive holes, playing (1 + 2 + 3 + 4) + (1 + 2 + 3) = £16.
So, in total Ian pays £32 for the 13 holes he lost.
From 8 holes there are 6 ways that runs of 5 and 1 can be made:
And there are 2 ways that runs of 4 and 3 can be made:
So if John wins 5+1 and Ken wins 4+3 there are 12 possibilities.
And if John wins 4+3 and Ken wins 5+1 there are also 12 possibilities.
Giving 24 possible ways to achieve the required games.
Manually, we see that the boys won 13 holes between them, so the possible splits are (8, 5) or (7, 6).
Winning 8 holes would give a prize of T(8) which must be more than the winnings from 5 holes. So the splits are (7, 6).
Possible consecutive runs for 7 (and corresponding prizes) are:
Possible runs for 6 (and corresponding prizes) are:
The only overlap is for a prize of £16, with consecutive runs of (3, 4) and (1, 5).
LikeLike
Jim Randell 11:04 am on 29 January 2022 Permalink |
Here’s an alternative approach, which instead of generating the numbers of the holes won, finds possible runs of wins among the 8 holes.
It is slightly faster than my original solution (above).
Run: [ @replit ]
from enigma import (irange, decompose, tri, intersect, printf) # generate possible runs of <n> wins for <k> holes def generate(n, k): # split n into j parts for j in irange(1, k + 1 - n): yield from decompose(n, j, sep=0) # consider winning runs totalling 5-8 holes on an 8 hole course X = dict() for n in irange(5, 8): X[n] = set(sum(tri(x) for x in ws) for ws in generate(n, 8)) # consider number of holes won by J for j in irange(5, 8): k = 13 - j # look for equal winnings for w in intersect([X[j], X[k]]): printf("I pays {t} [J wins {j}; K wins {k}]", t=w + w)LikeLike