Enigmatic Code

Programming Enigma Puzzles

Enigma 1644: Same goal average

From New Scientist #2810, 30th April 2011 [link]

Albion, Borough, City, Rangers and United have played in a soccer tournament in which each team played each of the others once. No two matches in the tournament had the same score, and no team scored more than three goals in any match. Albion drew against Borough; both of these teams won their other three matches.

Over the whole tournament Albion and Borough had the same goal average (calculated by dividing goals scored by goals conceded) but Albion had the better goal difference (goals scored minus goals conceded).

What were the scores in Albion’s four matches? Give each score in the form xy, with Albion’s score first in each match.

[enigma1644]

Advertisements

One response to “Enigma 1644: Same goal average

  1. jimrandell 7 December 2011 at 3:06 pm

    The following Python code runs in 32ms.

    from itertools import combinations
    
    # possible scores for X v Y
    scores = set()
    for X in range(1, 4):
      for Y in range(0, X):
        scores.add((X, Y))
    
    
    # for the draw
    for d in range(0, 4):
    
      # for A
      for A in combinations(scores, 3):
        fA = d + sum(x[0] for x in A)
        aA = d + sum(x[1] for x in A)
    
        # for B
        for B in combinations(scores.difference(A), 3):
          fB = d + sum(x[0] for x in B)
          aB = d + sum(x[1] for x in B)
    
          if not(fA * aB == fB * aA): continue
          if not(fA - aA >  fB - aB): continue
      
          print('A:', ((d, d),) + A, fA, aA)
          print('B:', ((d, d),) + B, fB, aB)
    

    Solution: Albion’s scores were: 3-3, 3-2, 3-1, 3-0.

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: