### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,114)
- misc (2)
- project euler (2)
- puzzle (29)
- site news (43)
- tantalizer (29)
- teaser (3)

### Site Stats

- 166,224 hits

Programming Enigma Puzzles

29 April 2015

Posted by on **From New Scientist #2393, 3rd May 2003** [link]

George recently suffered a nightmare involving a seemingly bottomless drawer containing large numbers of socks of each of the seven colours of the rainbow. Old Nick whispered in George’s ear that if he selected two socks at random from the drawer the odds were exactly even that they would be the same colour.

The ghost of George’s mother-in-law then appeared, declared a distaste for violet socks, and threw out all the socks of that colour. With six colours remaining, the devil repeated that two socks selected at random had a 50:50 chance of being the same colour.

Four more ghosts appeared and threw out in turn all the indigo, blue, green and yellow socks. The Devil repeated his assertion each time, with reducing numbers of colours, that a pair selected at random had a 50:50 chance of being the same colour.

“There are 25 socks left, but how many have been thrown out?” George asked the Devil.

“I don’t give straight answers,” replied the Devil, “but I can tell you that it is an exact multiple of the original number of socks of your favourite colour.”

What is that multiple, and what is George’s favourite colour?

[enigma1237]

Advertisements

%d bloggers like this:

This Python program runs in 527ms.

Solution:The multiple is 121. George’s favourite colour is yellow.There are 10 and 15 socks that are red and orange (but we don’t know which number is associated with which colour), 51 yellow socks, 153 green socks, 459 blue socks, 1377 indigo socks and 4131 violet socks. With all seven colours there are 6196 socks in total. 6171 (= 121×51) of them are thrown out to leave the 25 red and orange socks.

So apart from the colour with 10 socks all the other colours have an odd number of socks.

I think I’m right in saying that the numbers of red and orange socks must be two consecutive triangular numbers, summing to a square number. The number of yellow socks is one more than twice that square. After that, the number of each successive colour is three times the previous. So the smallest set of numbers could be 1 red and 3 orange (4 socks remaining, rather than 25 in the puzzle as set), 9 yellow, 27 green, 81 blue, 243 indigo, 729 violet. Sum 1093, of which 1089 = 121×9 are thrown out. Not quite as nightmarish, but still a lot of socks for a man to possess.

In this case it’s all odd numbers — rather like my sock drawer, in fact.

Hugh, your logic looks right to me. Perhaps the setter expected objections because you can no longer find a pair of red socks!

Continuing your analysis a bit…

The sequence goes: S(n) = [T(n-1), T(n), (3^k)(2n² + 1), …] k=0..4, for n > 1.

With the first two terms summing to n² (the remaining socks), and the other 5 terms, which are the discarded socks, are a geometric sequence that sums to (3^5 – 1)/2 × (2n² + 1) = 121(2n² + 1) = 121 × (the 3rd element of the sequence).

So for any sequence S(n) the sum of the final 5 terms is always 121 times the third term, so we can arrive at an answer, without knowing n.

For n=1 (S=[0, 1, 3, 9, 27, 81, 243]) and n=2 (S=[1, 3, 9, 27, 81, 243, 729]) are there multiple terms that divide the number of discarded socks ([1, 3] and [1, 3, 9] respectively).

In the puzzle we are told there are 25 socks remaining, so n²=25, hence n=5, S=[10, 15, 51, 153, 459, 1377, 4131].

3 stars it deserves a star for the entertaining text in the question.