Enigmatic Code

Programming Enigma Puzzles

Enigma 341: Spot the score

From New Scientist #1490, 9th January 1986 [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 and so on, looks like this:

Enigma 341

(2 points are given for a win and 1 point to each side in a draw).

Find the score in each match.

[enigma341]

Advertisements

One response to “Enigma 341: Spot the score

  1. Jim Randell 22 April 2016 at 9:24 am

    This Python program uses the new susbstituted_table() and substituted_table_goals() routines from the Football() helper class in the enigma.py library (see Enigma 246). So, you’ll need the latest version of enigma.py to run it. It runs in 96ms.

    from enigma import Football, irange, concat
    
    # the scoring system
    football = Football(points={ 'w': 2, 'd': 1 })
    
    # numbers in the table stand for themselves (and use 'A' for 10)
    d = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, 'A': 10  }
    
    # find possible match outcomes
    for (matches, d) in football.substituted_table({ 'played': '?3??', 'points': '1?02' }, d=d):
      # choose goals for A and goals for D values
      # these must sum to (6 + 6 + 6 + 3) - (10 + 5) = 6
      for x in irange(0, 6):
        # find possible scores
        for scores in football.substituted_table_goals(concat(x, 'A5', 6 - x), '6663', matches, d=d):
          # output the matches and their scores
          football.output_matches(matches, scores, teams='ABCD')
    

    Solution: The scores in the matches are: A vs B = 1-1; A vs D = 0-5; B vs C = 6-5; B vs D = 3-0. Matches A vs C and C vs D 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: