Enigmatic Code

Programming Enigma Puzzles

Enigma 1477: In transit

From New Scientist #2639, 19th January 2008

Six air travellers had to change planes at Gatwick airport. Mr and Mrs Apex landed at 08:00, Mr and Mrs Club landed at 08:10 and Mr and Mrs Economy landed at 08:15.

Then, one of the men and one of the women departed at 08:45, another man and woman departed at 8:55 and the remaining man and woman departed at 09:10.

All six people had a different length of time between landing and departing, with more than one husband having a shorter wait than his wife.

List the six names in increasing order of the time they spent waiting between landing and departing.



One response to “Enigma 1477: In transit

  1. Jim Randell 3 December 2012 at 9:59 pm

    The following Python program runs in 35ms.

    from itertools import permutations, product
    from enigma import sprintf
    # consider the departure times
    # the different times are distributed amongst each gender group 
    for (th, tw) in product(permutations((45, 55, 70)), repeat=2):
      # compute the waiting times
      (Ah, Aw) = (th[0], tw[0])
      (Ch, Cw) = (th[1] - 10, tw[1] - 10)
      (Eh, Ew) = (th[2] - 15, tw[2] - 15)
      # all waiting times are different
      if len(set((Ah, Aw, Ch, Cw, Eh, Ew))) != 6: continue
      # husbands that wait shorter than their wives
      hs = list((h, w) for (h, w) in ((Ah, Aw), (Ch, Cw), (Eh, Ew)) if h < w)
      if len(hs) < 2: continue
      # output the result
      r = list(sorted(zip((Ah, Aw, Ch, Cw, Eh, Ew), product("ACE", ("Mr", "Mrs")))))
      print(', '.join(sprintf("{w}m: {p[1]} {p[0]}") for (w, p) in r))

    Solution: The travellers in order of waiting time (from shortest wait to longest) are: Mr Economy, Mrs Club, Mrs Economy, Mr Apex, Mr Club, Mrs Apex.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: