Enigmatic Code

Programming Enigma Puzzles

Tantalizer 466: Diplomacy

From New Scientist #1017, 9th September 1976 [link]

In the early years of this century, when the lamps were going out all over Europe, Lord Grey asked his advisers whether Bosnia would ally with Austria. They gave thought to the question but could only answer in hypotheticals.

If, they said, Bosnia allies with Austria, Montenegro will ally with Hungary. If Slovakia allies with Denmark, Finland will ally with Serbia. If Albania allies with Slovakia, Poland will ally with Transylvania. If Montenegro allies with Hungary, Latvia will ally with Poland. If Bosnia allies with Austria, then, unless Slovakia allies with Denmark, Finland will ally with Serbia. If Poland allies with Transylvania, Finland will not ally with Serbia. If Latvia allies with Poland then, if Rumania allies with Austria, Poland will ally with Transylvania. If Montenegro allies with Hungary and Albania does not ally with Slovakia, then Rumania will ally with Austria.

They added, of course, that “if x then y” implies neither “if y then x” nor “if not x then not y”. But they could not answer the original question. Assuming all the hypotheticals to be true, can you?

[tantalizer466]

One response to “Tantalizer 466: Diplomacy

  1. Jim Randell 6 December 2017 at 8:23 am

    This Python program examines all truth values for the 8 alliances. It runs in 65ms.

    Run: [ @repl.it ]

    from itertools import product
    from enigma import printf
    
    # logical implication
    implies = lambda p, q: not(p) or q
    
    # do the 8 alliances satisfy the hypothetical statements
    def satisfy(BA, MH, SD, FS, AS, PT, LP, RA):
      return all([
        # BA -> MH
        implies(BA, MH),
        # SD -> FS
        implies(SD, FS),
        # AS -> PT
        implies(AS, PT),
        # MH -> LP
        implies(MH, LP),
        # BA -> (not(SD) -> FS)
        implies(BA, implies(not(SD), FS)),
        # PT -> not(FS)
        implies(PT, not(FS)),
        # LP -> (RA -> PT)
        implies(LP, implies(RA, PT)),
        # MH and not(AS) -> RA
        implies(MH and not(AS), RA),
      ])
    
    # choose a value for BA
    for BA in (True, False):
      # can we satisfy the remaining alliances
      for (MH, SD, FS, AS, PT, LP, RA) in product((True, False), repeat=7):
        if satisfy(BA, MH, SD, FS, AS, PT, LP, RA):
          printf("BA={BA} [MH={MH} SD={SD} FS={FS} AS={AS} PT={PT} LP={LP} RA={RA}]")
          break
    

    Solution: It is not possible for Bosnia to ally with Austria.

    But it is possible for Bosnia not to ally with Austria. The easiest scenario for this is the one where no-one allies with anyone else, but there are 20 scenarios for the remaining 7 alliances where Bosnia is not allied with Austria.

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: