Enigmatic Code

Programming Enigma Puzzles

Puzzle 23: Football (Letters for digits – 3 teams)

From New Scientist #1074, 20th October 1977 [link]

In the following football puzzle letters have been substituted for digits. The same letters stand for the same digit whenever it appears, and different letters stand for different digits. Three teams — AB and C — are to play each other once, and the table below gives some information about numbers of matches played, won, lost, etc., after some — or perhaps all — of the matches had been played.

Find the score in each match.

[puzzle23]

One response to “Puzzle 23: Football (Letters for digits – 3 teams)

  1. Jim Randell 8 May 2019 at 8:00 am

    We can solve this puzzle using the [[ Football() ]] helper class from the enigma.py library.

    This Python program runs in 80ms.

    Run: [ @repl.it ]

    from enigma import Football, irange, update
    
    # scoring system
    football = Football(points=dict(w=2, d=1))
    
    # label the teams
    (A, B, C) = (0, 1, 2)
    
    # possible digits
    digits = set(irange(0, 9))
    
    # the table (minus the goals columns)
    table = dict(played='?g?', w='??k', d='?tt', points='??x')
    
    # solve the table
    for (ms, d) in football.substituted_table(table):
    
      # choose a value for n
      for n in digits.difference(d.values()):
    
        # determine the scores in each match (using the goals values for A and B)
        d2 = update(d, [('n', n)])
        for ss in football.substituted_table_goals('nk?', 'xn?', ms, d=d2, teams=[A, B]):
    
          football.output_matches(ms, ss, teams='ABC', d=d2)
    

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

    The A vs B match is 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: