Teaser 2724: Headcount
From The Sunday Times, 7th December 2014 [link] [link]
My grandson and I play a coin game. First we toss seven coins and I have to predict in advance the number of heads whilst he has to predict the number of tails. I then get a number of points equal to the number of heads, he gets a number of points equal to the number of tails, and anyone whose prediction was correct gets a fixed bonus number of points (less than 40). We repeat this with six coins in the second round, then five, and so on down to two. In a recent game we noticed that, after each round, the total of all the points so far awarded was equal to a prime number.
What is the “fixed bonus” number of points? And what was the total of all the points at the end of the game?
[teaser2724]
Jim Randell 7:30 am on 12 July 2022 Permalink |
(See also: Teaser 3009).
In a round with n coins the points awarded are, the number of heads (+ bonus if guessed correctly) and the number of tails (+ bonus if guessed correctly). So n points are always awarded, along with 0, 1, or 2 bonuses.
We don’t need to worry about the points won by each player, just the total number of points gained in each round.
This Python program keeps a set of (total, bonus) pairs, and then progresses through the rounds keeping viable values.
It runs in 57ms. (Internal runtime is 664µs).
Run: [ @replit ]
from enigma import (irange, is_prime, printf) # start with a total of 0, and all possible bonus values ss = set((0, x) for x in irange(0, 40)) # start with <k> coins k = 7 # consider subsequent rounds while k > 1: ss_ = set() # consider (total, bonus) in the previous round for (t, b) in ss: # consider number of bonuses awarded in this round for n in (0, 1, 2): t_ = t + k + n * b if is_prime(t_): ss_.add((t_, b)) # move on to the next round (ss, k) = (ss_, k - 1) # output solutions for (t, b) in ss: printf("total = {t}, bonus={b}")Solution: The number of bonus points is 19. The total number of points at the end of the game is 103.
The progression of the game is:
LikeLike