Brain teaser 977: Little boy blue
From The Sunday Times, 12th April 1981 [link]
The baby department of our local store has just organised a raffle. The tickets were numbered consecutively from one upwards and were made into large books, each containing the same number of consecutive tickets.
Numbers having at least one repeated digit were printed on blue paper and those having all their digits different were printed on pink paper. It turned out that there was an equal number of blue and pink tickets. The prize was a generously equipped layette in the colour of the winning ticket.
Being the first person to buy a ticket, I had the opportunity to see that among the large collection of books only one of them consisted of tickets all of the same colour, and it was the colour I wanted too.
Spoilt for choice, I bought the ticket in the middle of this book. My choice was fully justified: I won the prize!
What was my winning number?
The version of the puzzle published in the book Microteasers (1986), also includes the additional question:
How many tickets were there?
The puzzle is also included in the book The Sunday Times Book of Brainteasers (1994).
[teaser977]
















Jim Randell 9:09 am on 16 April 2023 Permalink |
This Python program runs in 72ms. (Internal runtime is 13.0ms).
from enigma import ( irange, inf, is_duplicate, divisors_pairs, seq_all_same, singleton, printf ) blue = pink = 0 ts = [None] # there is no ticket 0 # look for books with tickets the same colour def same_colour(ts, n, k): for i in irange(1, n, step=k): if seq_all_same(ts[i] for i in irange(i, i + k - 1)): yield i # consider number of tickets for n in irange(1, inf): f = is_duplicate(n) ts.append(f) if f: blue += 1 else: pink += 1 if blue == pink: printf("total={n} [blue={blue} pink={pink}]") # consider j books, each with k tickets done = 0 for (j, k) in divisors_pairs(n, every=1): # k is odd (and > 1) if not (k > 1 and k % 2 == 1): continue # find books with tickets all the same colour b = singleton(same_colour(ts, n, k)) if b is None: continue printf("-> {j} books, each with {k} tickets -> {b} .. {x}", x=b + k - 1) if k % 2 == 1: # find the middle ticket t = b + (k // 2) printf("-> middle ticket = {t}") done += 1 if done: breakSolution: The winning number was: 10073.
There were 44 books, each with 255 tickets, making 11220 tickets in total. 5610 of them are blue, and 5610 of them are pink.
The book of tickets from 9946 – 10200 consists of 255 tickets, all of which have repeated digits, so are coloured blue.
The ticket in the middle of this book is 10073 (there are 127 tickets before it and 127 tickets after it).
LikeLike
Hugo 10:48 am on 16 April 2023 Permalink |
Is it possible that there were 187 tickets per book? In that case there would be a book 9912 – 10098,
with middle number 10005. If it had been fewer than 187, there would be two all-blue books.
I think the longest possible run with repeated digits is 357, from 9877 to 10233.
LikeLike
Frits 11:28 am on 16 April 2023 Permalink |
@Hugo, as 187 is less than 220 (there are 11220 tickets in total) the last book must be all-blue as well (all tickets of the form 11xxx).
LikeLike