Teaser 2881: A month of meetings
From The Sunday Times, 10th December 2017 [link] [link]
In one particular month this year I had one-day meetings in each of Geneva, London, Rome, Tallinn, Venice and York. For any two of these cities their names had at least one letter in common precisely when the days of their meetings (1st, 2nd, 3rd …) had no common factor larger than one. No two meetings were on the same day of the week (e.g., no two meetings were on Wednesdays). The Geneva meeting was the first and the London meeting was the last, the London meeting being on a Friday.
What was the date of the Tallinn meeting (month and day)?
The original puzzle text used the spelling “Tallin”. In the text above I’ve used the more usual spelling, but the puzzle works with either.
[teaser2881]









Jim Randell 8:11 am on 18 February 2020 Permalink |
This Python 3 program runs in 372ms.
Run: [ @repl.it ]
from datetime import date from enigma import (irange, gcd, unpack, cached, printf) # the set of letters in a string def letters(s): return set(x for x in s.lower() if x.isalpha()) # return the number of letters shared by two strings @cached def share_letters(a, b): return len(letters(a).intersection(letters(b))) # find dates for places <ps>, starting from date <d0> # s = (place, date) pairs allocated so far def solve(ps, d0, s=[]): # are we done? if not ps: yield s else: p = ps[0] # choose a date for d in irange(d0, 31): # no meetings are on the same day of the week if any((d - d1) % 7 == 0 for (p1, d1) in s): continue # places have a letter in common iff their dates are coprime if any(bool(share_letters(p, p1)) != (gcd(d, d1) == 1) for (p1, d1) in s): continue # solve for the remaining places yield from solve(ps[1:], d0, s + [(p, d)]) # the Geneva meeting was first, so choose a date for that for dG in irange(1, 26): # solve for the remaining places (except London) for s1 in solve(['Rome', 'Tallinn', 'Venice', 'York'], dG + 1, [('Geneva', dG)]): # and then solve for London (last meeting) dM = max(d for (p, d) in s1) for s in solve(['London'], dM + 1, s1): # find a month in 2017 where the London meeting is a Friday (_, dL) = s[-1] for m in irange(1, 12): try: d = date(2017, m, dL) except ValueError: continue # Friday is weekday 4 if d.weekday() != 4: continue # output a solution (ordered by date) for (p, d) in sorted(s, key=unpack(lambda p, d: d)): printf("{d} {p}", d=date(2017, m, d).strftime("%a %d %b %Y")) printf()Solution: The Tallinn meeting was on Wednesday 22nd March 2017.
There are two possible itineraries:
LikeLike