### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,818 hits

Advertisements

Programming Enigma Puzzles

20 January 2014

Posted by on **From New Scientist #2513, 20th August 2005**

Joe’s daughter has been asking him for weeks to make a wind chime. So this week Joe cut a length of stainless steel tubing into 10 lengths from 1 cm to 10 cm in steps of 1 cm. He also cut out a disc from a sheet of stainless steel and drilled 10 evenly spaced holes round the perimeter and one in the centre.

Joe hung one tube from each hole and hung the disc up by a thread from its centre. That was a big mistake as the disc tilted right over.

So Joe rearranged the tubes until the disc balanced perfectly. In making a note of the lengths of the tubes in order round the disc the result was an 11-digit number.

What is the smallest of all the 11-digit numbers Joe could have written down?

[enigma1354]

Advertisements

%d bloggers like this:

This Python program calculates the centre of mass for each arrangement of tubes, and then determines the smallest of the numbers corresponding to balanced discs. Since it’s using Python’s

floatsit checks the centre of mass is “close enough” to the centre of the disc. For a completely accurate (but slower) solution, you can importsin, cos, pifromsympy(instead ofmath), and check of the centre of mass corresponds exactly to the centre of the disc – you get the same results.The Python program below runs in 291ms (under PyPy).

Solution:The smallest 11-digit number is 10145892367.Here is a version that avoids the approximations involved in using floating point arithmetic by using complex integers (x + i.y with x and y integer) to represent the algebraic cosine and sine values.

Here is another variation. The reasoning behind the code is in a

Blog postThis is a recursive Python solution that uses the analysis that opposite pairs of adjacent weights sum to the same value (i.e if the weights are numbered from w0 to w9 around the circle, then w0 + w1 = w5 + w6, w1 + w2 = w6 + w7, w2 + w3 = w7 + w8, w3 + w4 = w8 + w9, w4 + w5 = w9 + w0).

It runs in 35ms – much faster than computing the centre of mass of all combinations.