Enigmatic Code

Programming Enigma Puzzles

Tantalizer 411: Diplomatic niceties

From New Scientist #961, 7th August 1975 [link]

When H.M.G.’s five top ambassadors all fell under the same bus, there was an immense fuss about their replacements. The corridors of power hummed with insinuations, until at last a list of five names and a set of conditional agreements was achieved. The latter read:

1. If Sir Basil Brace does not get Paris, Sir Emlyn Entry shall have Bonn or Rome.
2. If neither Sir Ambrose Amble nor Sir Donald Duck gets Washington, Sir Crispin Carruthers shall have Paris.
3. If Sir Ambrose Amble does not get Bonn, Sir Crispin Carruthers or Sir Emlyn Entry shall have Paris.
4. If Sir Donald Duck does not get Rome, then, if Sir Ambrose Amble does not get Paris, Sir Emlyn Entry shall have Moscow.
5. If Sir Ambrose Amble does not get Washington, then, if Sir Donald Duck does not get Moscow, Sir Crispin Carruthers shall have Bonn.

Having been duly warned that “if x then y” does not mean or imply “if not x then not y”, can you assign the top chaps to the right places?

[tantalizer411]

One response to “Tantalizer 411: Diplomatic niceties

  1. Jim Randell 26 February 2020 at 7:19 am

    We can consider all possible assignments of people to places, and then check the conditions to see if they are satisfied.

    This Python program runs in 81ms.

    Run: [ @repl.it ]

    from enigma import subsets, printf
    
    # logical implication: p -> q = "if p, then q"
    implies = lambda p, q: not(p) or q
    
    # assign people to places
    for (B, M, P, R, W) in subsets("ABCDE", size=5, select="P"):
    
      # 1. "If B does not get Paris, then E shall have Bonn or Rome"
      if not implies(P != "B", B == "E" or R == "E"): continue
    
      # 2. "If neither A nor D gets Washington, then C gets Paris"
      if not implies(W != "A" and W != "D", P == "C"): continue
    
      # 3. "If A does not get Bonn, then C or E gets Paris"
      if not implies(B != "A", P == "C" or P == "E"): continue
    
      # 4. "If D does not get Rome, then (if A does not get Paris, then E gets Moscow)"
      if not implies(R != "D", implies(P != "A", M == "E")): continue
    
      # 5. "If A does not get Washington, then (if D does not get Moscow, C gets Bonn)"
      if not implies(W != "A", implies(M != "D", B == "C")): continue
    
      printf("Bonn = {B}, Moscow = {M}, Paris = {P}, Rome = {R}, Washington = {W}")
    

    Solution: Amble to Washington; Brace to Moscow; Carruthers to Paris; Duck to Rome; Entry to Bonn.

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: