Enigmatic Code

Programming Enigma Puzzles

Enigma 1600: Double-barrelled

From New Scientist #2765, 19th June 2010 [link]

I have several barrels, each of which can hold a whole number of litres of wine, where none of the numbers is a perfect square.

If I take pairs of the barrels in every possible combination, I can measure out an almost complete sequence of 11 consecutive integral volumes with only one volume, 100 litres, missing from the series and no volumes either extra or duplicated.

What, in ascending order, are the capacities of the barrels in litres?



One response to “Enigma 1600: Double-barrelled

  1. jimrandell 10 January 2012 at 9:42 pm

    The following Python program runs in 102ms.

    # in order to make a sequence of 10 pairs we need 5 barrels.
    # if the sequence is around 100 the smallest possible sequence is:
    # <90, 91, 92, 93, 94, 95, 96, 97, 98, 99> and the largest is:
    # <101, 102, 103, 104, 105, 106, 107, 108, 109, 110>, so all the numbers
    # must be less than 110 (and larger than 1)
    from itertools import combinations
    squares = set(i*i for i in range(1, 12))
    values = set(range(90, 111)).difference((100,))
    for A in range(2, 110):
      if A in squares: continue
      for B in range(A, 110):
        if B in squares: continue
        AB = A + B
        if not AB in values: continue
        for C in range(B, 110):
          if C in squares: continue
          p3 = set(x + C for x in (A, B))
          if not p3.issubset(values): continue
          if max(p3) - min(p3) > 10: continue
          for D in range(C, 110):
            if D in squares: continue
            p4 = set(x + D for x in (A, B, C))
            if not p4.issubset(values): continue
            if len(p4) != 6: continue
            if max(p4) - min(p4) > 10: continue
            for E in range(D, 110):
              if E in squares: continue
              p5 = set(x + E for x in (A, B, C, D))
              if not p5.issubset(values): continue
              if len(p5) != 10: continue
              if max(p5) - min(p5) != 10: continue
              print((A, B, C, D, E), sorted(p5))

    Solution: The volumes of the barrels are 48l, 51l, 53l, 54l and 55l.

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: