Enigmatic Code

Programming Enigma Puzzles

Enigma 259: Half burnt

From New Scientist #1406, 19th April 1984 [link]

“Just for once,” said Uncle Bungle, “I will make up a football puzzle in which all the information is included, instead of one with about half the figures left out.”

He undoubtably meant well — my uncle nearly always does. But as so often his plan went sadly wrong. He was doing a bit of tidying up and the wrong piece of paper — or rather half of it — got thrown on the fire.

All that was left was this:

Enigma 259

(2 points are given for a win and 1 point for a draw).

Calling the five teams A, B, C, D and E in that order find who played whom and the score in each match.

(They are all to play each other once eventually. C had not yet played E).



One response to “Enigma 259: Half burnt

  1. Jim Randell 18 February 2015 at 7:59 am

    This Python program uses the Football() helper class from the enigma.py library. It runs in 50ms.

    from enigma import Football, printf
    # set the scoring rules
    football = Football(points={ 'w': 2, 'd': 1 })
    # the 10 matches are:
    # AvB AvC AvD AvE BvC BvD BvE CvD CvE DvE
    # CvE has not been played
    # both A and D have no points, so AvD cannot have been played
    CE = AD = 'x'
    # consider the possible remaining matches 
    # (they cannot be wins or draws for A or D)
    for (AB, AC, AE, BC, BD, BE, CD, DE) in football.games('lx', 'lx', 'lx', 'wdlx', 'wx', 'wdlx', 'wx', 'lx'):
      # check the points for B, C, E
      B = football.table([AB, BC, BD, BE], [1, 0, 0, 0])
      if B.points != 7: continue
      C = football.table([AC, BC, CD, CE], [1, 1, 0, 0])
      if C.points != 3: continue
      E = football.table([AE, BE, CE, DE], [1, 1, 1, 1])
      if E.points != 4: continue
      # now examine possible scorelines for D
      for (sAD, sBD, sCD, sDE) in football.scores([AD, BD, CD, DE], [1, 1, 1, 0], 0, 2):
        # remaining scorelines for C
        for (sAC, sBC, sCE) in football.scores([AC, BC, CE], [1, 1, 0], 4, 0, [sCD], [0]):
          # remaining scorelines for A
          for (sAB, sAE) in football.scores([AB, AE], [0, 0], 4, 10, [sAC, sAD], [0, 0]):
            # remaining scoreline (for B)
            for (sBE,) in football.scores([BE], [0], 9, 5, [sAB, sBC, sBD], [1, 0, 0]):
              # check scorelines for E
              if football.goals([sAE, sBE, sCE, sDE], [1, 1, 1, 1]) != (7, 7): continue
              printf("AB={AB}:{sAB} AC={AC}:{sAC} AD={AD}:{sAD} AE={AE}:{sAE} BC={BC}:{sBC} BD={BD}:{sBD} BE={BE}:{sBE} CD={CD}:{sCD} CE={CE}:{sCE} DE={DE}:{sDE}")

    Solutions: The scores in the matches played are: AvB 2-3, AvC 0-4, AvE 2-3, BvC 0-0, BvD 1-0, BvE 5-3, DvE 0-1. All other matches are not yet played.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: