From The Sunday Times, 18th April 1982 [link]
The Manager of a large company greeted his twelve new computer staff. “You have been given consecutive, five-digit, Staff Reference Numbers (SRN). I remember numbers by finding their prime factors, using mental arithmetic — pre-computer vintage. Why not try it? If you would each tell me what factors you have, without specifying them (and ignoring unity), I should be able to work out your SR numbers”.
John said: “My number is prime.”
Ted said ” I have two prime factors. Your number follows mine doesn’t it, Les?”
Ian said: “I also have two, one of which squared. Alan’s just before me on the list.”
Sam said: “One of mine is to the power four. The last two digits of my SRN give me the other prime factor.”
Pete said: “I’ve got one factor to the power four as well. The other one is my year of birth.”
Brian said: “My number has one prime factor cubed and two others, both squared.”
Chris said: “I’m the only one with four factors, one of which is squared. Fred’s number is one less than mine.”
Dave started to say: “Kevin’s SRN is the one after mine, which …” when the Manager interrupted. “I can now list all twelve!”
List the twelve people, by initials, in increasing order of SRNs. What is Sam’s SRN?
This was the final puzzle to go by the title “Brain teaser“. The next puzzle was “Brainteaser 1030“.
This puzzle is included in the book The Sunday Times Book of Brainteasers (1994).
[teaser1029]
Jim Randell 7:52 am on 20 July 2025 Permalink |
Although not explicitly stated, I am assuming the booklet consists of the minimum number of A4 sheets required to fit all pages of both chapters.
Here is a constructive solution, that constructs the pairs of pages and organises them into A4 sheets, and then looks for a scenario where the sheets can be split as required. (This allows easy output of the page numbers on each A4 sheet, if desired).
The following Python program runs in 60ms. (Internal runtime is 539µs).
Run: [ @codepad ]
from enigma import (irange, divc, div, chunk, chain, printf) # pages for chapter 1 n1 = 34 # consider the number of pages in chapter 2 (< n1) for n2 in irange(1, n1 - 1): # pair up the pages pairs = list(chunk(chain(irange(1, n1), irange(1, n2)), 2)) # total sum of all page numbers divided by 2 s = div(sum(map(sum, pairs)), 2) if s is None: continue # total number sheets of A4 required t = divc(n1 + n2, 4) # collect the page numbers for each sheet sheets = [()] * t for (i, p) in zip(chain(irange(t), irange(t, step=-1)), pairs): sheets[i] += p # can we find some sheets that sum to s ? x = 0 for k in irange(t): x += sum(sheets[k]) if x == s: # output solution printf("chapter 2 has {n2} pages [{t} sheets in total; first {k} sheets sum to {x}]", k=k + 1) if x >= s: breakSolution: Chapter 2 has 25 pages.
There are 15 A4 sheets, and the page numbers are as follows:
The sum of the page numbers of sheets 1-9 and sheets 10-15 both come to 460.
If we can construct the booklet with more than the minimum required number of A4 sheets, then it is possible to construct a further solution:
If chapter 2 has 14 pages and the booklet was printed from 17 sheets, then the sum of the page numbers on sheets 1-12 and sheets 13-17 would both come to 350 (and there would be 20 blank pages at the end of the booklet).
This justifies the initial assumption.
The program can be used to investigate similar puzzles where the number of pages in the first chapter is other than 34.
An interesting case is when chapter 1 has 19 pages. There are then 2 solutions:
LikeLike
Jim Randell 9:15 am on 20 July 2025 Permalink |
Here is a faster version of my program that works with a list of the sum of pairs of pages on a leaf.
It has an internal runtime of 124µs.
from enigma import (irange, chunk, div, divc, seq_get, printf) # pages for chapter 1 n1 = 34 # page pair sums from chapter 1 pairs = list(map(sum, chunk(irange(1, n1), 2))) t = sum(pairs) get = seq_get(pairs, default=0) # consider the number of pages in chapter 2 (< n1) for (i, n2) in enumerate(irange(1, n1 - 1), start=n1): # make the pair sum of the final page if i % 2: pairs[-1] += n2 else: pairs.append(n2) t += n2 s = div(t, 2) if s is None: continue # now look for sheets that sum to s, by pairing up page sums (x, k) = (0, len(pairs)) if k % 2 == 0: k -= 1 for i in irange(divc(k, 2)): x += get(i) + get(k - i) if x == s: # output solution printf("chapter 2 has {n2} pages [first {i} sheets sum to {x}]", i=i + 1) if x >= s: breakLikeLike
Frits 2:45 pm on 20 July 2025 Permalink |
One loop.
The sum of 4 page numbers per sheet can only have 2, 3 or 4 different values (per number of pages in chapter 2).
It took a while before I figured out how the booklet was constructed.
# one folded A4 sheet results in 4 pages t = 17 * 35 # sum(1...34) # number of pages in chapter 2 for n in range(1, 34): # sum of all pages t += n # both <isum> as <osum> are even so <h> must also be even if t % 4: continue h = t // 2 n_sheets = (37 + n) // 4 n_inner_sheets = 17 - n_sheets # calculate starting page number of most inner sheet st = 2 * ((n + 1) // 4) + 17 # calculate sum of 4 outer sheet page numbers (except most outer sheet) osum = (2 * (n + n % 2) - 1) + 3 if n > 1 else -1 # calculate sum of most inner sheet page numbers isum = 4 * st + 6 if n_sheets < 17 else osum # can we make <h> using <k> sheets (beginning from the center)? # h = a.isum + b.osum or b = (h - a.isum) / osum # use maximum <n_inner_sheets> inner sheets and possible <b> outer sheets d, r = divmod(h, isum) if not r and d <= n_inner_sheets: print("answer:", n) else: # h - n_inner_sheets * inner = b * osum b, r = divmod(h - n_inner_sheets * isum, osum) if not r and 0 < b <= n_sheets - n_inner_sheets: if osum > 0: print("answer:", n)LikeLike