Skip to content

Sunday Times Teaser 2993 – Baker’s Weights

by Peter Good

Published February 02 2020 (a palindrome 02-02-2020!)  (link)

A baker’s apprentice was given a 1kg bag of flour, scales and weights, each engraved with a different whole number of grams. He was told to separately weigh out portions of flour weighing 1g, 2g, 3g, and so on up to a certain weight, by combining weights on one side of the scales. He realised that he couldn’t do this if there were fewer weights, and the largest weight was the maximum possible for this number of weights, so he was surprised to find after one of these weighings that the whole bag had been weighed out. Upon investigation, he discovered that some of the weights weighed 1g more than their engraved weight. If I told you how many of the weights were too heavy, you would be able to work out what they all were.

What were the actual weights (in ascending order)?

5 Comments Leave one →
  1. Brian Gladman permalink

  2. Erling Torkildsen permalink

  3. GeoffR permalink

    Hi Erling

    I noticed you are using a fairly narrow range to look for a solution
    when you say you are considering all possible arrangements of weights:

    in line 19: ie for t in range(40, 46):

    Is there a logical reason why these limits are used and should it not be apparent with a comment in your code?

    Geoff

    • Erling Torkildsen permalink

      Hi Geoff

      Thanks for commenting.

      ‘All possible arrangements of weights’ refers to all the 64 possible combinations of normal and overweight weights. From (1g, 2g, 4g, 8g, 16g, 32g) -> (2g, 3g, 5g, 9g, 17g, 33g). All possible number of weighings are not considered. That is justified by the fact that the largest number of weigings to empty the bag of flour occurs when all weights are normal (former case) and smallest when all weights are overweight (latter case).
      By the function rw(s, t), defined in line 11-12, we have rw((0, 0, 0, 0, 0, 0), 44) = 990 and rw((1, 1, 1, 1, 1, 1), 41) = 966, and in both cases, for the next value of t the real weights exceed 1000. And as the values increase monotonically, the range you refer to, in fact, could have been set even narrower.
      (To be honest, I had those values in a spreadsheet before I wrote the programme, and that is where I (by convenience) get them from now. But that does not alter the justification above.)

      Erling

    • Erling Torkildsen permalink

      PS: To Geoff: Forgot to mention that I accept the critic that it should have been justified by a comment in the code.

Leave a comment to Brian Gladman Cancel reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS