Teaser 2554: Odd and even
From The Sunday Times, 4th September 2011 [link] [link]
Roddy and Eve have a set of cards on which is written a consecutive sequence of whole numbers, one number on each card. Roddy challenges Oliver to choose two cards at random, promising a prize if the sum of the numbers is odd. Eve issues the same challenge, but offers a prize for an even sum. Oliver accepts the challenge that gives him the greater probability of winning. This probability is a whole number percentage and, when reversed, it gives the two-digit number of cards.
Whose challenge did Oliver accept and how many cards are there?
[teaser2554]






Jim Randell 7:37 am on 1 May 2025 Permalink |
We can consider sets of cards numbered 1 .. n, as if each card has a offset x from these values, then the sum of the pairs is increased by 2x, and this doesn’t change whether the sum is odd or even.
The percentage must be > 50%, and it is the reverse of the number of cards.
This Python program runs in 77ms. (Internal runtime is 16ms).
from enigma import (irange, subsets, div, nrev, printf) # consider 2-digit percentages >50% for p in irange(51, 99): # reverse is the number of cards n = nrev(p) if n < 10: continue # count odd/even pairs t = [0, 0] for (x, y) in subsets(irange(1, n), size=2): t[(x + y) % 2] += 1 T = sum(t) # calculate higher probability as a percentage x = max(t) q = div(100 * x, T) if q == p: # output solution printf("n={n} -> t={t} p={p}% (= {x}/{T})")Solution: There are 25 cards. Oliver chooses Roddy’s challenge.
With 25 cards there are C(25, 2) = 300 ways of choosing a pair of cards.
144 of them give an even total, and 156 of them give an odd total.
So the probability of choosing cards that give an odd total is:
LikeLike
Frits 6:06 pm on 1 May 2025 Permalink |
# only consider odd number of cards, n = 10 * a + b # number odd sums = 1st even * 2nd odd + 1st odd * 2nd even # ((n - 1) // 2) * ((n + 1) // 2) + ((n + 1) // 2) * ((n - 1) // 2) or # (n**2 - 1) / 2 # percentage = number odd / (n * (n - 1) = (n + 1) / (2 * n) # a whole number percentage and, when reversed, # it gives the two-digit number of cards # 100 * ((10 * a + b) + 1) / ((10 * a + b) * 2) = 10 * b + a # 500 * a + 50 * b + 50 = (a + 10 * b) * (10 * a + b) # 10 * a**2 + (101 * b - 500) * a + 10 * b**2 - 50 * b - 50 = 0 for b in range(5, 10, 2): a, r = divmod(500 - 101 * b + 3 * (1089 * b**2 - 11000 * b + 28000)**.5, 20) if r: continue print(f"There are {10 * int(a) + b} cards. " f"Oliver chooses Roddy's challenge")LikeLike