Enigmatic Code

Programming Enigma Puzzles

Puzzle 21: Cricket (4 teams)

From New Scientist #1072, 6th October 1977 [link]

A, B, C and D have all played each other once at cricket.

Points are awarded as follows:

To the side that wins — 10
To the side that wins on the first innings in a drawn match — 6
To the side that loses on the first innings in a drawn match — 2
To each side for a tie — 5
To the side that loses — 0

A, B, C and D got 10, 11, 17 and 14 points respectively, and you are told that only one match was won outright.

Find the result of each match.

[puzzle21]

One response to “Puzzle 21: Cricket (4 teams)

  1. Jim Randell 5 June 2019 at 9:40 am

    We’ve encountered similar puzzles before. See: Enigma 3, Puzzle 59, Puzzle 32.

    This Python program runs in 173ms.

    Run: [ @repl.it ]

    from itertools import product
    from enigma import printf
    
    # possible scores
    scores = ( (10, 0), (6, 2), (5, 5), (2, 6), (0, 10), (0, 0) )
     
    # possible scores in the matches
    for s in product(scores, repeat=6):
    
      # only one match was won outright (i.e. (10, 0) or (0, 10))
      if sum((10 in x) for x in s) > 1: continue
    
      # calculate the overall totals
      (AB, AC, AD, BC, BD, CD) = s
      A = AB[0] + AC[0] + AD[0]
      B = AB[1] + BC[0] + BD[0]
      C = AC[1] + BC[1] + CD[0]
      D = AD[1] + BD[1] + CD[1]
      if not((A, B, C, D) == (10, 11, 17, 14)): continue
    
      printf("AB={AB} AC={AC} AD={AD} BC={BC} BD={BD} CD={CD}")
    

    Solution: The results are:

    A vs B = (2 – 6) B won on the first innings
    A vs C = (2 – 6) C won on the first innings
    A vs D = (6 – 2) A won on the first innings
    B vs C = (5 – 5) tie
    B vs D = (0 – 10) D won
    C vs D = (6 – 2) C won on the first innings

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: