Enigmatic Code

Programming Enigma Puzzles

Enigma 358: Add up the scores

From New Scientist #1507, 8th May 1986 [link]

In the following football table and addition sum letters have been substituted for digits (from 0 to 9). The same letter stands for the same digit wherever it occurs and different letters stand the different digits.

The four teams are eventually going to play each other once – or perhaps they have already done so. The score in each match is different.

Enigma 358 - Table

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

Enigma 358 - SUM

Find the scores in the football matches and write the addition sum out with numbers substituted for letters.

[enigma358]

Advertisements

One response to “Enigma 358: Add up the scores

  1. Jim Randell 19 August 2016 at 8:19 am

    This kind of problem can be solved with a combination of the Football.substituted_table*() and SubstitutedSum() solvers from the enigma.py library.

    This Python program runs in 73ms.

    from enigma import Football, SubstitutedSum
    
    # scoring system
    football = Football(points={ 'w': 2, 'd': 1 })
    
    # solve the table (to get: g h k m p)
    for (matches, d) in football.substituted_table({ 'played': '???g', 'w': 'k?m?', 'l': '???k', 'd': 'hh??', 'points': 'pgg?' }):
    
      # solve the sum (to get: j r y)
      p = SubstitutedSum(['jk', 'pj'], 'yr', l2d=d)
      for s in p.solve():
    
        # determine the scores
        for scores in football.substituted_table_goals('jjrp', 'mjry', matches, d=s):
    
          # check the scores are all different
          if len(set(tuple(sorted(x)) for x in scores.values())) != len(scores): continue
    
          # output the matches
          football.output_matches(matches, scores, teams='ABCD', d=s)
    

    Solution: The scores in the played matches are: A vs B = 1-0; A vs C = 0-0; A vs D = 3-0; B vs C = 2-2; B vs D = 2-1; C vs D = 4-4. The addition sum is: 42 + 54 = 96.

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: