Enigmatic Code

Programming Enigma Puzzles

Enigma 363: Incomplete statistics

From New Scientist #1512, 12th June 1986 [link]

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

Enigma 363

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

Find the score in each match.

This is the 1000th puzzle posted to the site in the enigma category. However, since there are a couple of duplicate puzzles (Enigma 83 duplicates Enigma 9, and Enigma 1770 duplicates Enigma 1757) I’m holding off claiming we’ve got to 1000 Enigma Puzzles until next week (and it also means I don’t have to celebrate the 1000th puzzle by posting a football problem).

[enigma363]

Advertisements

2 responses to “Enigma 363: Incomplete statistics

  1. Jim Randell 23 September 2016 at 7:51 am

    This program uses the Football() helper class from the enigma.py library. It’s not particularly fast (it runs in 1.56s), but it is quite short. (This is helped by the fact that we don’t have to consider possible match outcomes for the A vs F match, as it always turns out to be unplayed).

    from enigma import Football, printf
    
    # scoring system
    football = Football(points={ 'w': 2, 'd': 1 })
    
    # labels for the teams
    (A, B, C, D, E, F) = (0, 1, 2, 3, 4, 5)
    
    # digits stand for themselves
    d = dict((x, int(x)) for x in '0123567')
    
    # solve the table
    for (ms, _) in football.substituted_table({ 'played': '2?1??2', 'w': '?1????', 'points': '?5?32?' }, d=d, teams=[B, C, A, F, D, E]):
    
      # determine the scores for matches other than A vs F
      for ss in football.substituted_table_goals('?5362?', '?5201?', ms, d=d, teams=[C, E, D, B]):
    
        # check the goals for F (which we can work out if A v F is not yet played)
        assert ms[(A, F)] == 'x'
        (f, a) = football.goals([ss[(x, F)] for x in (A, B, C, D, E)], [1] * 5)
        if a != 7: continue
        
        # output the matches
        football.output_matches(ms, ss, teams='ABCDEF')
    

    Solution: The scores in the played matches are: A vs B = 1-1; A vs E = 0-2; B vs C = 2-3; B vs D = 0-0; B vs E = 1-0; B vs F = 1-1; D vs F = 6-0. The following matches are not yet played: A vs C; A vs D; A vs F; C vs D; C vs E; C vs F; D vs E; E vs F.

    Here is the complete table:

    enigma-363-solution

  2. Hugh Casement 23 September 2016 at 12:38 pm

    I can’t pretend to be sorry to see the last of that run of football puzzles: an average of about one a month for fifteen months from March 1985.  They must have been scraping the bottom of the barrel — or did the editor really imagine we enjoy such puzzles??&nbsp: Not very imaginative, are they?

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: