### 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

10 June 2016

Posted by on **From New Scientist #1497, 27th February 1986** [link]

I went to three parties in succession. At each one I was surprised to see an identical cake, bought at the Bêtisserie Noire, and on each occasion the cake was divided equally among all those present, including me.

When I arrived home (what a dog I felt!) I realised to my embarrassment that I had eaten altogether the equivalent of exactly half a cake. Of course, I could have done that by going to three parties with five people at each, so that there would have been 18 pieces of cake at all three parties. But how dull that would have been! However, just as reversing 18 gives 81, a perfect square, so too reversing the digits in the total number of pieces of cake involved in that triple binge produces a perfect square. Is it a two-digit square? Really, I shan’t hand you the answer on a plate.

How many people did I encounter at each party?

[enigma348]

Advertisements

%d bloggers like this:

This Python program runs in 36ms.

Solution:The three parties had 2, 6 and 41 other guests (not including the setter).Including the setter there were 3, 7 and 42 guests at the parties. So altogether there would be 3 + 7 + 42 = 52 pieces of cake.

1/3 + 1/7 + 1/42 = 14/42 + 6/42 + 1/42 = 21/42 = 1/2.

The

generate()function can be used to generate sequences of numbers whose reciprocals sum to a specified fraction. Themparameter can be used to specify a minimum value for the numbers, and thegparameter can be used to specify the minimum gap between numbers (so if you want all the numbers to be different setg=1).The number of solutions for numbers whose reciprocals sum to unity is given by OEIS A002966 (and if the numbers are all required to be different (

g=1) OEIS A006585).This Enigma follows on from Enigma 1062.