Enigmatic Code

Programming Enigma Puzzles

Enigma 625: Unlucky arrow

From New Scientist #1779, 27th July 1991 [link]

Four football teams are to play each other once. After some of the matches have been played, a table giving some details of the matched played (P), won (W), lost (L) and goals for (F) and against (A), looked like this:

enigma-625

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

Find the score in each match played so far.

[enigma625]

One response to “Enigma 625: Unlucky arrow

  1. Jim Randell 31 May 2021 at 10:16 am

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

    The following Python program runs in 63ms.

    Run: [ @replit ]

    from enigma import Football, digit_map
    
    # scoring system
    football = Football(games='wdlx', points=dict(w=2, d=1))
    
    # numbers in the table stand for themselves
    d = digit_map()
    
    # the table
    (table, gf, ga) = (dict(played='??2?', w='?01?', l='???0', points='0???'), '?594', '?541')
    
    # determine the match outcomes
    for (m, _) in football.substituted_table(table, d=d):
    
      # determine the scores in the matches (only process teams B, C, D)
      for s in football.substituted_table_goals(gf, ga, m, d=d, teams=[1, 2, 3]):
    
        # output the matches and scores
        football.output_matches(m, s, teams="ABCD")
    

    Solution: The scores in the played matches are: A vs C = 0-5; A vs D = 0-3; B vs C = 4-4; B vs D = 1-1.

    The A vs B and C vs D matches are not yet played.

    The complete table looks like this:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.