Enigmatic Code

Programming Enigma Puzzles

Tantalizer 469: Revised version

From New Scientist #1020, 30th September 1976 [link]

Mr Chips was sodden with gloom after marking the R.I. test. Admittedly no one had scored nought, which was unusual. (In fact the scores were all different). But, alas, the other pupils had done better than the only four Christians in the class.

After some soul-searching he realised that it was his duty to adjust the marks. So he began by adding to each pupil’s score the number of marks gained in the test by all the other pupils. That was better but the resulting list left something to be desired. So he then subtracted from each pupil’s new score three times his or her original score. That was much more satisfactory. The scores were all positive and totalled 116 marks in all. The heathen Blenkinsop was rightly bottom and could therefore be made to write out the 119th psalm.

How many did Blenkinsop score before and after Mr Chips did his duty?

[tantalizer469]

One response to “Tantalizer 469: Revised version

  1. Jim Randell 8 November 2017 at 7:04 am

    If there are n pupils (4 Christians plus some others, so we consider n > 5), and the total number of original marks is T.

    The first attempt to fudge the marks, consists of adding the marks of all the other pupils to each pupils original mark. This makes each pupils mark up to T. So indeed the revised list would leave something to be desired.

    The next attempt is to remove three times the original mark from the current mark (which is T), so if the pupil originally scored x the final mark is (T − 3x). (So if all the original marks are different, so are all the final marks). And the sum of all these final marks is 116:

    If we label original marks a, b, c, … then the sum of the final marks are:

    (T − 3a) + (T − 3b) + (T − 3c) + …
    = nT − 3(a + b + c + …)
    = nT − 3T
    = (n − 3)T

    And we are told that this total is 116, so we can consider divisors of 116.

    This Python 3.6 program runs in 78ms.

    Run: [ @repl.it ]

    from enigma import divisors, irange, printf
    
    # decompose t into n distinct numbers (in increasing order)
    def decompose(t, n, m=1, s=[]):
      if n == 1:
        if not(t < m):
          yield s + [t]
      else:
        for x in irange(m, t // n):
          yield from decompose(t - x, n - 1, x + 1, s + [x])
    
    # the total of the final marks
    X = 116
    
    # consider values for T
    for T in divisors(X):
      # compute n
      n = X // T + 3
      if n < 6: continue
    
      # find a valid sequence of original marks
      for s in decompose(T, n):
        # compute the final marks
        f = list(T - 3 * x for x in s)
        assert sum(f) == X
        if any(x < 1 for x in f): continue
    
        # the bottom final mark will come from the top original mark
        printf("T={T} n={n}: original marks = {s}, final marks = {f}")
        printf("  -> Blenkinsop: original = {s[-1]}, final = {f[-1]}")
    

    Solution: Originally Blenkinsop came top with 8 marks. In the final table Blenkinsop was bottom with 5 marks.

    The original marks (from lowest to highest) were 1, 2, 3, 4, 5, 6, 8.

    The final corresponding marks were: 26, 23, 20, 17, 14, 11, 5.

    The ordering of pupils is reversed by the fudging of the marks. The Christians marks are the first four elements of each list.

    If we take a less strict reading of “other pupils” to allow only 1 other pupil (n = 5), then we can find multiple solutions.

Leave a Comment

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