Enigmatic Code

Programming Enigma Puzzles

Enigma 512: Sufficient evidence

From New Scientist #1664, 13th May 1989 [link]

Four football teams are to play each other once. After some of the matches have been played a document giving some details of the matches played, won, lost and so on looked like this:

Enigma 512

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

Find the score in each match.

[enigma512]

One response to “Enigma 512: Sufficient evidence

  1. Jim Randell 12 August 2019 at 8:37 am

    It turns out the B cannot have lost any matches, so they only have 1 draw and so their “goals for” and “goals against” values must be the same (i.e. 3), and this means C’s “goals for” must be 7. This is enough information to allow the [[ Football() ]] helper class from the enigma.py library to determine the match outcomes and scorelines.

    This Python program runs in 101ms.

    Run: [ @repl.it ]

    from enigma import Football, digit_map
    
    # scoring system
    football = Football(points=dict(w=2, d=1))
    
    # labels for the teams
    (A, B, C, D) = (0, 1, 2, 3)
    
    # values stand for themselves (and go up to 12)
    d = digit_map(0, 12)
    
    # columns of the table (without goals for/against)
    table = dict(played='2?2?', w='10??', l='???2', d='?1??', points='???1')
    
    # find possible match outcomes
    for (ms, _) in football.substituted_table(table, d=d):
    
      # check B only has drawn games ...
      tB = football.table([ms[(A, B)], ms[(B, C)], ms[(B, D)]], [1, 0, 0])
      assert tB.w == tB.l == 0 
    
      # ... so B's "goals for" and "goals against" are the same (= 3) and
      # so C's "goals for" must be 7, and we can calcuate the scorelines
      for ss in football.substituted_table_goals("5375", "530C", ms, d=d):
    
        # output solution
        football.output_matches(ms, ss, teams="ABCD")
    

    Solution: The scores are: A vs C = 0-3, A vs D = 5-2, B vs D = 3-3, C vs D = 4-0. The other matches remain 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: