Enigmatic Code

Programming Enigma Puzzles

Puzzle 4: Football (4 teams. Old method)

From New Scientist #1054, 9th June 1977 [link]

Four football teams, A, B, C and D, are to play each other once. After some — or perhaps all — of the matches have been played a table giving some details of matches played, won, lost, etc, looked like this:


(2 points are given for a win and one point to each site in a drawn match).

Find the score in each match.


One response to “Puzzle 4: Football (4 teams. Old method)

  1. Jim Randell 19 February 2020 at 8:11 am

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

    Run: [ @repl.it ]

    from enigma import Football, digit_map, irange, sprintf
    # scoring system
    football = Football(points=dict(w=2, d=1))
    # numbers in the table stand for themselves
    d = digit_map(0, 7)
    # determine the outcomes in the matches
    for (m, d) in football.substituted_table(dict(w='?1??', d='?1?0', points='??10'), d=d):
      # suppose: "goals for C" = x and "goals for D" = y, then:
      # "goals for" = "goals against", 7 + 2 + x + y = 7 + 0 + 3 + 4, so: x + y = 5
      for x in irange(0, 5):
        y = 5 - x
        # determine the scores
        for s in football.substituted_table_goals(sprintf('72{x}{y}'), '7034', m, d=d):
          # output the matches and scores
          football.output_matches(m, s, teams='ABCD')

    Solution: The scores in the played matches are: A vs B = 0-2; A vs C = 3-2; A vs D = 4-3; B vs C = 0-0.

    The B vs D and C vs D 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 )

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: