Enigmatic Code

Programming Enigma Puzzles

Enigma 1443: Fantasy century

From New Scientist #2604, 19th May 2007

It pains me that the two fastest cricket match centuries (by Viv Richards in 1986 off 56 balls and by Adam Gilchrist in 2006 off 57 balls) have both been scored against my namesake team. I retaliated by scoring a century off even fewer balls against the bowling of Shane Warne and Glenn McGrath and thus forced them into retirement.

In reaching my century I faced balls off which I had scores of 0, 1, 2, 4 and 6 runs, a different perfect square number of balls for each of these scores.

Exactly how many runs had I scored in total after completing the runs from the ball that bought me to my century?



One response to “Enigma 1443: Fantasy century

  1. Jim Randell 8 April 2013 at 8:42 am

    The following Python program runs in 44ms.

    from itertools import permutations
    from enigma import irange,printf
    scores = (0, 1, 2, 4, 6)
    squares = list(i * i for i in irange(1, 7))
    for p in permutations(squares, 5):
      # number of balls bowled
      n = sum(p)
      if not(n < 56): continue
      # total score
      s = sum(a * b for (a, b) in zip(p, scores))
      if not(s > 99): continue
      # what was the score 1 ball before
      for (i, j) in enumerate(scores):
        if p[i] < 1: continue
        t = s - scores[i]
        if not(t < 100): continue
        printf("score = {s} ({t} + {b}) [balls={n} {z}]", b=scores[i], z=list(zip(p, scores)))

    Solution: The total number of runs when the century was achieved is 103.

    There are two different ways that the century could be achieved:

    9 balls scoring 0, 25 balls scoring 1, 4 balls scoring 2, 16 balls scoring 4, 1 ball scoring 6


    25 balls scoring 0, 1 ball scoring 1, 16 balls scoring 2, 4 balls scoring 4, 9 balls scoring 6

    In each case the century is scored off 55 balls, and in each case the score off the ball that gives the century could be a 4, taking the score from 99 to 103, or a 6, taking the score from 97 to 103.

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: