Enigmatic Code

Programming Enigma Puzzles

Enigma 330: Enigmatic table

From New Scientist #1478, 17th October 1985 [link]

The four teams Alphas, Betas, Gammas and Deltas are part way through their football season, in which each plays each of the others once. Part of the league table (with the teams in decreasing order) is given below with digits consistently replaced by letters. Three points are awarded for a win and one for a draw.

Enigma 330

There’s only one entry in Alpha’s row — and that’s wrong! It should in fact be lower than the entry implies. Luckily the rest is right.

List the matches played so far and the score in each.



One response to “Enigma 330: Enigmatic table

  1. Jim Randell 29 January 2016 at 4:05 pm

    Another football problem.

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

    from enigma import Football, irange, printf
    # scoring regime
    football = Football(points={ 'w': 3, 'd': 1 })
    # start with the matches for G
    for (AG, BG, GD) in football.games(repeat=3):
      tG = football.table([AG, BG, GD], [1, 1, 0])
      (E, N, I, A) = (tG.played, tG.w, tG.l, tG.points)
      ds0 = set([E, N, I, A])
      if len(ds0) != 4: continue
      # remaining matches for B
      for (AB, BD) in football.games(repeat=2):
        tB = football.table([AB, BG, BD], [1, 0, 0])
        G = tB.points
        ds1 = ds0.union([G])
        if E != tB.played or A > G or len(ds1) != 5: continue
        # remaining match
        for AD in football.games():
          tD = football.table([AD, BD, GD], [1, 1, 1])
          if A != tD.played or I != tD.l or tD.points > A: continue
          tA = football.table([AB, AG, AD], [0, 0, 0])
          if G > tA.points: continue
          # possible values for M
          for M in set(irange(0, 9)).difference(ds1):
            # determine the scores in B's matches
            for (sAB, sBG, sBD) in football.scores([AB, BG, BD], [1, 0, 0], M, G):
              # determine the scores in G's remaining matches
              for (sAG, sGD) in football.scores([AG, GD], [1, 0], G, M, [sBG], [1]):
                # the goals for/against D in the matches that we know are:
                (fD, aD) = football.goals([sBD, sGD], [1, 1])
                # so the goals for A in the A v D match are:
                gA = E - aD
                if gA < 0: continue
                if gA > 0 and AD == 'x': continue
                # the goals for/against A in the matches that we know are:
                (fA, aA) = football.goals([sAB, sAG], [0, 0])
                if not(fA + gA < G): continue
                printf("AB={AB}:{sAB} AG={AG}:{sAG} AD={AD}:{gA}-? BG={BG}:{sBG} BD={BD}:{sBD} GD={GD}:{sGD}")
                printf("E={E} N={N} I={I} G={G} M={M} A={A}")

    Solution: The scores in the matches played are: A v B = 1-0; A v G = 1-0; B v G = 3-3; B v D = 2-0; G v D = 1-1.

    The A v D match is the only one remaining to be 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 )

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: