Sunday Times Teaser 2887 – A Convivial Dinner Party
by Angela Newing
Published January 21 2018 (link)
Three married couples, the Blacks, the Grays and the Pinks, are having dinner together seated around a circular table. The three men had provided one course each towards the dinner. Each lady was sitting between two men, neither being her husband. The first names are Henry, Robin, Tom, Jenny, Monica and Naomi. Robin and Mr Pink go to the same gym as the wife of the provider of the starter and Mrs Gray. The main course provider, an only child, has Monica on his right. The starter provider doesn’t have a sister. The dessert came from someone sitting closer to Naomi than he is to Mrs Black. Henry is brother in law to the starter provider and his only sister is on his left. Tom’s wife made the coffee, while the other two ladies washed up.
What were the full names of all the ladies?
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859from itertools import permutations, product# married couples are opposite each other; <pos> holds the# positions clockwise around the table with upper/lower case# for Mr/Mrs respectively (B/b, G/g, P/p = Brown, Gray, Pink)pos = ['B', 0, 0, 'b', 0, 0]# for the positions of the starter, main and dessert providerscpr = [' '] * 6# for the position of the christian namesnms = [' '] * 6# consider both possible positions for the Grays and the Pinksfor a, b in permutations('GP'):pos[1], pos[2], pos[4], pos[5] = a.lower(), b, a, b.lower()# now consider all combinations of course providers (male)# male and female namesfor cp, mn, fn in product(permutations('DMS'),permutations('HRT'),permutations('JMN')):cpr[0], cpr[2], cpr[4] = cpnms[0], nms[2], nms[4] = mnnms[1], nms[3], nms[5] = fn# Mrs Grey is not the starter provider's wifeif pos[(cpr.index('S') + 3) % 6] == 'g':continue# Mr Pink is not Robinif nms[pos.index('P')] == 'R':continue# the main course provider is an only child (so cannot be Harry who# has a sister) and has Monica on his rightif nms[(cpr.index('M') - 1) % 6] != 'M' or nms[cpr.index('M')] == 'H':continue# Harry has his sister, the starter provider's wife, on his leftif (nms.index('H') + 1) % 6 != (cpr.index('S') + 3) % 6:continue# The dessert provider is closer to Naomi than to Mrs Blackpd = cpr.index('D')if nms[(pd + 3) % 6] == 'N' or (pos.index('b') - pd) % 6 != 3:continue# output the full names clockwise around the tablefor i in range(6):sn = ('Black', 'Grey', 'Pink')['BGP'.index(pos[i].upper())]if i & 1:rs, nm, fd = 'Mrs', ('Jenny', 'Monica', 'Naomi')['JMN'.index(nms[i])], ''else:rs, nm = 'Mr', ('Henry', 'Robin', 'Tom')['HRT'.index(nms[i])]fd = ('(starter)', '(main course)', '(dessert)')['SMD'.index(cpr[i])]print(f'{rs} {nm} {sn} {fd}')print()