Brain-Teaser 512: [Five nieces]
From The Sunday Times, 4th April 1971 [link]
When I first met the Problem Setter, and let on that I was interested in his line of entertainment, he immediately told me that he had five nieces all going to the same primary school where each girl was entered on her fourth birthday and on each subsequent birthday morning was moved up into the next form.
Forms I-III were the Infants section to which they all still belonged. Tomorrow (Tuesday) one of the five would have a birthday, on Wednesday another. Which?
To get me going, he gave me their names in order of seniority and told me which niece would be in which form on Wednesday.
I said all I could usefully deduce from this was that Alice wasn’t one of the celebrants; I couldn’t be at all sure of any of the other four; I was aware, needless to say, that Alice, though younger than Emily, was older than Isabel, and that Olive was older than Ursula, but would I be right in guessing that Wednesday’s celebrant was older than Tuesday’s? (This necessitating that Ursula and Olive were currently in the same form).
When he said yes, I knew the answer, so …
Whose birthday [was on] on Tuesday, and whose [was] on Wednesday?
This puzzle was originally published with no title.
[teaser512]
Jim Randell 11:47 am on 10 December 2019 Permalink |
I did this one manually before I wrote a program.
This Python program looks at the girls in ascending age order, and the possible assignment of forms, such that the setter would be unable to deduce any celebrants, and only deduce one non-celebrant. From the information given we can then assign to the girls and verify the remaining conditions. It runs in 80ms.
Run: [ @repl.it ]
from collections import defaultdict from itertools import product from enigma import subsets, irange, tuples, intersect, diff, join, printf # update a sequence with (<index>, <delta>) pairs def update(s, *ps): s = list(s) for (i, v) in ps: s[i] += v return tuple(s) # is a sequence ordered? def is_ordered(s): return not any(x > y for (x, y) in tuples(s, 2)) # indices for the girls girls = list(irange(0, 4)) # record the celebrants by their forms (on Wednesday) r = defaultdict(list) # choose the forms that the girls are in on Wednesday for fs in subsets([1, 2, 3, 4], size=5, select="R"): # at most 2 girls can be promoted to form 4 if fs.count(4) > 2: continue # choose the girls with birthdays on Tuesday and Wednesday for (Tu, We) in subsets(girls, size=2, select="P"): # the situation on Tuesday fsT = update(fs, (We, -1)) if 0 in fsT or not is_ordered(fsT): continue # the situation on Monday fsM = update(fsT, (Tu, -1)) if 0 in fsM or 4 in fsM or not is_ordered(fsM): continue r[fs].append((Tu, We)) # for each key determine girls that definately are or aren't celebrants for (fs, vs) in r.items(): # we can't positively identify any celebrant pos = intersect(vs) if pos: continue # we can only negatively identify one non-celebrant neg = set(girls).difference(*vs) if len(neg) != 1: continue # that non-celebrant is A A = neg.pop() # I and E are either side of A for (I, E) in product(girls[:A], girls[A + 1:]): # and U and O are the other two (in that order) (U, O) = diff(girls, (A, E, I)) # we are then told Wednesday's celebrant is older than Tuesday's for (Tu, We) in vs: if not(We > Tu): continue # and U and O are in the same form on Monday fsM = update(fs, (We, -1), (Tu, -1)) if not(fsM[U] == fsM[O]): continue # output solution d = dict(zip((A, E, I, O, U), "AEIOU")) s = join((join((d[i], '=', x)) for (i, x) in enumerate(fsM)), sep=", ") printf("Tu={Tu} We={We}; Mon=[{s}]", Tu=d[Tu], We=d[We])Solution: Isabel’s birthday is on Tuesday. Olive’s birthday is on Wednesday.
The order of the girls (youngest to oldest) is: I, U, A, O, E.
LikeLike