From The Sunday Times, 9th July 1989 [link]
Five families, each consisting of a mother, father, and one child, are near neighbours. The families have a lot in common, and, to give you some idea of the closeness, I will tell you that last Saturday all 15 family members went on an outing to the circus to celebrate young Laura’s 10th birthday.
The day before that, four of the mothers, Jenny, Lorna, Margaret and Norma, had been on a shopping spree together, and two of the fathers, Ken and John, had prepared a barbecue for all the others. Three of the children, Kevin, Marion and Nigel, are learning the piano under the same teacher.
Mike and Neil are the fathers of daughters. Young Jill, who is not Neil’s child, shares a birthday with Leo’s child (who has the same initial as Mike’s wife) and with Kate’s child (who has the same initial as Leo’s wife). The other two children share a birthday on a different date.
If I tell you that no two members of a family have the same first name initials as each other, you should be able to work out the name of John’s wife and who it was that shared Laura’s birthday last week.
There are now 1400 Teaser puzzles available on the site, so it seemed like an appropriate time to post Teaser 1400.
Between S2T2 and Enigmatic Code there are now 4056 puzzles available in total.
[teaser1400]
Jim Randell 6:33 am on 22 November 2026 Permalink |
Very straightforward.
This Python program runs in 68ms. (Internal runtime is 164µs).
from enigma import (powers, irange, inf, group, mod, seq2str, fmts, printf) # generate candidate PINs def pins(): # consider squares up to 4-digits for n in powers(0, inf, 2): if n > 9999: break # how many of the divisors give a remainder of 1? k = sum(1 for d in irange(2, 9) if n % d == 1) if k == 7: yield n # group candidate PINs by the final digit g = group(pins(), by=mod(10)) # look for categories with only 1 entry for (k, ns) in g.items(): if len(ns) != 1: continue printf("final digit {k} -> PIN = {ns}", ns=seq2str(ns, sort=1, fn=fmts("04d"), sep=" ", enc=""))Solution: [To Be Revealed]
The setter does not want to reveal the PIN, but telling us that the final digit would reveal the PIN does allow us to work it out.
LikeLike
Frits 8:34 am on 22 November 2026 Permalink |
Assuming that a 4-digit PIN doesn’t start with a zero.
def check(n): c = 0 for i in range(2, 10): c += ((n % i) != 1) if c > 2: return False return (c == 1) # odd 4-digit squares sqs = [i * i for i in range(33, 100, 2)] # candidate PINs cands = [n for n in sqs if check(n)] # dictionary of candidates per odd last digit d = {i: [n for n in cands if n % 10 == i] for i in range(1, 10, 2)} print(f"answer: {' or '.join(str(ns[0]) for ns in d.values() if len(ns) == 1)}")LikeLike
Jim Randell 8:40 am on 22 November 2026 Permalink |
@Frits: I think it is allowable for a PIN to have leading zeros.
LikeLike
Frits 9:50 am on 23 November 2026 Permalink |
This time allowing leading zeroes.
is_square = lambda n: round(n**(0.5))**2 == n # number 2521 = (5 * 7 * 8 * 9) + 1 has remainder of 1 for all divisors 2..9 m = 2521 sols = set() # select the divisor that doesn't give a remainder of 1 for div in range(2, 10): inc = (m - 1 ) // div n = inc + 1 while n < 10000: if n not in sols and is_square(n): if sum(n % i == 1 for i in range(2, 10)) == 7: sols.add(n) n += inc # group candidates by last digit g = [[n for n in sols if n % 10 == i] for i in range(1, 10, 2)] print(f"answer: {' or '.join(str(ns[0]) for ns in g if len(ns) == 1)}")LikeLike
Frits 11:29 am on 23 November 2026 Permalink |
I don’t have proof that this method will generate all possible candidate solutions but it seems to do.
LikeLike
Jim Randell 3:36 pm on 23 November 2026 Permalink |
I did toy around with the following code to generate candidate PINs:
# generate possible PINs def pins(): # possible squares for 4-digit PINs sqs = set(first(powers(0, inf, 2), count=le(9999))) # possible divisors ds = list(irange(2, 9)) # consider possible failing divisors (z mod d != 1) for (i, d) in enumerate(ds): # find solutions for the other divisors m = call(mlcm, delete(ds, [i])) # if d divides m it is not a failing divisor if m % d == 0: continue # construct possible numbers for n in irange(m + 1, 9999, step=m): if n % d == 1 or n not in sqs: continue yield nBut in the end I decided it wasn’t worth the extra complexity.
LikeLike
ruudvanderham 1:01 pm on 22 November 2026 Permalink |
Note that this code requires istr >= 1.2.2
import istr import collections collect = collections.defaultdict(list) for pin in istr.squares(length=4, leading_zeroes=True): if sum(pin % j == 1 for j in range(2, 10)) == 7: collect[pin[-1]].append(pin) for last_digit, pins in collect.items(): if len(pins) == 1: print(pins[0])LikeLike