Teaser 2466: [Cracker game]
From The Sunday Times, 27th December 2009 [link]
In my Christmas cracker, there were four cards, each with eight numbers on:
first: 1, 3, 5, 7, 9, 11, 13, 15;
second: 2, 3, 6, 7, 10, 11, 14, 15;
third: 4, 5, 6, 7, 12, 13, 14, 15;
fourth: 8, 9, 10, 11, 12, 13, 14, 15.You ask someone to choose a number up to 15, then state which cards it is on; then (by a simple trick) you tell them their number.
I decided to make a version with more numbers, using the same technique but more than twice as many cards. It turned out that the numbers asked for below had equal sums of digits:
(a) How many numbers are on each card?
(b) What is the largest number?
This puzzle was originally published with no title.
[teaser2466]
Jim Randell 8:21 am on 24 December 2025 Permalink |
If we make a grid of which cards the number appears on (0 = doesn’t appear; 1 = does appear) we get this:
We see that the rows give a representation of the number in binary.
So when the cards containing the number are indicated we can reconstruct the original number by adding 1 if the 1st card is indicated, 2 if the 2nd card is indicated, 4 if the 3rd card is indicated, and 8 if the 4th card is indicated.
With n cards we can distinguish (2^n − 1) numbers (if 0 is not used). And each card has 2^(n − 1) numbers on it.
So we can look for values where these numbers have the same digit sum.
This Python program runs in 68ms. (Internal runtime is 147µs).
from enigma import (irange, inf, dsum, printf) # how many numbers can we distinguish with n cards? N = lambda n: (2**n) - 1 # how many numbers appear on each card? C = lambda n: 2**(n - 1) # consider n >= 4 for n in irange(4, inf): (Nn, Cn) = (N(n), C(n)) f = (dsum(Nn) == dsum(Cn)) printf("n={n}: N = {Nn}; C = {Cn}; f = {f}", f=int(f)) # are we done? if f and n > 8: breakSolution: (a) There are 4096 numbers of each card; (b) The largest number is 8191.
And:
There are 13 cards (each with 4096 numbers up to 8191 on them).
However this solution is not unique.
The next smallest solution is with 67 cards:
There are 73786976294838206464 numbers on each card, and the largest number is 147573952589676412927.
LikeLike
ruudvanderham 1:09 pm on 24 December 2025 Permalink |
import istr import peek for number_of_cards in istr.count(8): if sum(number_of_numbers := 2**number_of_cards - 1) == sum(largest_number := 2 ** (number_of_cards - 1)): peek(number_of_cards, number_of_numbers, largest_number) breakLikeLike