Teaser 3329: Ten cards
From The Sunday Times, 12th July 2026 [link] [link]
I have ten cards on which are written 20 different positive integers, with one integer on each side of the cards. The total of the integers on the front of the ten cards equals the total of the integers on the back. The total of the integers on each card is also the same.
The numbers on the front of the first nine cards are 2, 15, 17, 21, 24, 31, 35, 36 and 44. If I told you how many prime numbers are on the cards you should be able to tell me the two numbers on the tenth card.
In ascending order, what are the numbers on card ten?
[teaser3329]
















Jim Randell 5:50 am on 12 July 2026 Permalink |
If the front of the tenth card has a value of X, and the sum of the numbers on each card is N, then, by considering the total of the fronts and backs, we have:
Hence X is a multiple of 5.
The following Python program runs in 63ms. (Internal runtime is 87µs).
from enigma import (defaultdict, irange, inf, union, is_prime, ordered, singleton, printf) # the numbers on the front of the first 9 cards front = [2, 15, 17, 21, 24, 31, 35, 36, 44] # collect candidate solutions (= card 10) by the total number of primes rs = defaultdict(set) # consider the front of card 10 (= X) for X in irange(5, inf, step=5): if X in front: continue # determine the total for each card N = 45 + (X // 5) # and the back of card 10 (= Y) Y = N - X if Y < 1: break # the numbers on the back of the first 9 cards back = list(N - x for x in front) # the numbers on the cards are all different ns = union([front, back, (X, Y)]) if len(ns) != 20: continue # count the primes P = sum(1 for n in ns if is_prime(n)) # collect candidate solution printf("[X={X} N={N} -> {front} / {back} + [{X} / {Y}] -> {P} primes]") rs[P].add(ordered(X, Y)) # look for unique solutions for (k, vs) in rs.items(): v = singleton(vs) if v is not None: printf("{k} primes -> card 10 = {v}")If you are running under Python 3 you can use the following at line 23 to collect all the numbers into a
set:ns = { X, Y, *front, *back }Solution: The numbers on the tenth card are 9 and 45.
The cards are ((front, back), primes underlined):
The numbers on each card sum to 54, and the total of the fronts is 270 and the total of the backs is also 270.
The are two other candidate sets of cards that can be constructed, but they each have 7 primes:
LikeLike
Frits 11:20 am on 12 July 2026 Permalink |
from collections import defaultdict # front nine cards f9 = {2, 15, 17, 21, 24, 31, 35, 36, 44} # sum = 225 sumf9 = sum(f9) # primes in range 2 to (sum(f9) - 1) // 4 - 1 P = {3, 5, 7} P |= {2} | {x for x in range(11, (sum(f9) - 1) // 4, 2) if all(x % p for p in P)} d = defaultdict(list) # b = sum(f9) - 4 * t2 >= 1 or t2 <= (sum(f9) - 1) / 4 # possible totals of the integers on a card for t2 in range(max(f9) + min(set(range(1, max(f9) + 2)) - f9), (sumf9 - 1) // 4 + 1): # calculate front of the 10th card f = 5 * t2 - sumf9 if f in f9: continue f10 = f9 | {f} b10 = {t2 - n for n in f10} # 20 different positive integers if len(fb10 := f10 | b10) != 20: continue # store the 20 numbers for the number of prime numbers d[sum(n in P for n in fb10)] += [(t2, fb10)] # look for a unique solution for k, vs in d.items(): if len(vs) == 1: t, ns = vs[0] print(f"answer: {sorted(ns - f9 - {t - n for n in f9})}")LikeLike
Ruud 5:27 pm on 12 July 2026 Permalink |
import collections import types import istr collect = collections.defaultdict(list) first_nine_cards_front = [2, 15, 17, 21, 24, 31, 35, 36, 44] for sum_on_card in range(45, 100): for card10_front in range(1, 100): if card10_front in first_nine_cards_front: continue cards_front = first_nine_cards_front + [card10_front] cards_back = [] for card_front in cards_front: card_back = sum_on_card - card_front if card_back < 1 or card_back in cards_front + cards_back: break cards_back.append(card_back) else: if sum(cards_front) == sum(cards_back): number_of_primes = sum(filter(istr.is_prime, cards_front + cards_back)) collect[number_of_primes].append(types.SimpleNamespace(cards_front=cards_front, cards_back=cards_back)) for solutions in collect.values(): if len(solutions) == 1: print(solutions[0]) print("card10:", sorted([solutions[0].cards_front[-1], solutions[0].cards_back[-1]]))LikeLike