### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

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

### Site Stats

- 166,357 hits

Programming Enigma Puzzles

18 May 2014

Posted by on **From New Scientist #1337, 23rd December 1982** [link]

Mr Pickwick and his friends, Mr Snodgrass, Mr Tupman and Mr Winkle spent last Christmas together. “No children this year, alas,” observed Mr Pickwick on Christmas morning, “I am very fond of children.” But just then there was a knock on the front door. Opening it, Mr Pickwick beheld more than half a dozen children, who thereupon sang

. “Bless my soul!” he beamed and, fetching a tin of striped humbugs from the mantelpiece, shared them out equally and exactly among the children. The tin had once held a gross of humbugs but Mr Pickwick had already eaten some. Yet there were still enough (more than a hundred) to ensure that each child would receive more than half a dozen. In fact, if you knew how many Mr Pickwick had eaten himself, you could work out exactly how many each child got.God Rest Ye MerryGentlemenWith the carollers gone, it was time for presents. As usual each person gave, and each received, one scarf, one pair of gloves and one bottle of port. Each gave a present to each. Mr Pickwick gave gloves to the person who gave Mr Snodgrass a scarf; and Mr Winkle gave port to the person who gave Mr Tupman gloves.

The dinner was a true feast — a sizzling goose, which weighed 8lb plus half its own weight, pursued by a pudding decked with holly and enriched with as many silver coins as you could place bishops on a chess board without any attacking any square occupied by another. Afterwards came cigars. “I would have you know”, remarked Mr Pickwick, puffing contentedly, “that if cigar-smokers always told the truth and others never did, then Mr Snodgrass would say that Mr Winkle would deny being a cigar smoker. Furthermore Mr Tupman would say that Mr Winkle would deny that Mr Snodgrass smokes cigars”. After these and other pleasant exchanges the quartet retired a trifle unsteadily to bed.

Thus were Mr Pickwick’s Yuletide jollifications exceedingly merry. He wishes similar Christmastide celebrations for revellers everywhere.A few questions remain.

(1) How many humbugs had Mr Pickwick eaten himself?

(2) Who gave a bottle of port to whom? (four answers)

(3) What did the goose weigh?

(4) How many coins were hidden in the pudding?

(5) Was Mr Winkle a cigar-smoker?

(6) What are the four words ofa, b, c, dletters in the sentences initalics[or] such that:bold

a³ –a= 20bandb² = 2bcand 2b² =c²d.

This puzzle completes the archive of Enigmas from 1982.

There are now 650 puzzles on the site, with a full archive from the start of **Enigma** in 1979 to the end of 1982 (192 puzzles) and also puzzles from January 2005 up to the end of **Enigma** in December 2013 (457 puzzles) — which is just over 36.5% of all Enigma puzzles.

[enigma192]

Advertisements

%d bloggers like this:

I have written a separate Python program for each part of the problem.

(1) This code examines the possible number humbugs in the tin and eliminates those where there are multiple possibilities for the number of children and number of humbugs each receives. It runs in 32ms.

(2) This code examines all possible permutations of gift giving. It runs in 63ms.

(3) I’ve used SymPy to solve the equation (although it is easy to solve by hand). This program runs in 371ms.

(4) This is the hardest part of the problem. The following Python program examines all possible placements of bishops on an

N×Ngrid. I’ve assumed that the chessboard we’re interested in is an 8×8 grid, and the program runs in 1m46s in this case.(5) This program examines the possibilities for the preferences of the four friends. It runs in 30ms, but finds several solutions.

(6) This program extracts the words from the sentences, arranges them by number of letters and then looks for a collection of word lengths that satisfy the constraints. It runs in 44ms.

These programs can all be tied together with the following Python program:

Solution:(1) Mr Pickwick had eaten 23 humbugs from the tin. (2) The bottles of port were distributed as follows: from Mr Pickwick to Mr Snodgrass, from Mr Snodgrass to Mr Tupman, from Mr Tupman to Mr Winkle, and from Mr Winkle to Mr Pickwick. (3) The goose weighs 16 lb. (4) There were 14 coins hidden in the pudding. (5) It’s not possible to determine if Mr Winkle is a cigar smoker [*]. (6) The four words are: MERRY WISHES FOR YULETIDE [**].Some notes on the answers:

(1) The number of children (

n) and the number of humbugs each gets (g) must be the same, as we can’t distinguish betweennchildren receivingghumbugs (h = n×g) andgchildren receivingnhumbugs (h = g×n), so we need to find a square number between 10² and 12², so h=11², and hence there are 11 children and each gets 11 humbugs, meaning that Pickwick had already eaten 23 humbugs.(3) A straightforward solution to the equation w = 8 + w/2.

(4) See [ http://mathworld.wolfram.com/BishopsProblem.html ] for more information on the Bishop Problem.

(5) I’ve not been able to come up with a unique solution for W.

If we assign a truth value (t, f) to (S, T, W), such that X = t means X tells the truth (and so is a smoker), and X = f means X always lies (and is a non-smoker).

Then for a statement Y (that is true or false), “X states Y” is equivalent to X = Y.

We get the following statements:

So S is a liar (and a non-smoker).

And this fits with our intuition, as W cannot deny being a smoker. If W tells the truth (and so is a smoker) he would say “I am a smoker”, and if he lies (and so is a non-smoker) he would also say “I am a smoker”. So in order for S to report that W denies being a smoker, S has to be lying.

So we can’t determine the preferences of T and W, only that they are identical.

And again this fits with out intuition. S is not a smoker, so if W denies S is a smoker he is telling the truth, and if T tells us that W would deny S is a smoker then he is also telling the truth. However, if W does not deny that S is a smoker then he is lying, but T tells us that he does deny S is a smoker, so he is also lying.

Another alternative I considered was that smokers always lied and non-smokers always told the truth, that way everything P says is a lie, so we are looking for the negation of (A) and (B) (and of course X = t now corresponds to “X is a non-smoker”).

But that gets us the same results:

So S is a liar (and a smoker).

T and W have identical preferences.

I like to think the “best” solution is that P, S, T, W are all smoking and lying.

[*] The published solution is that Mr Winkle is a cigar smoker.

(6) There are also multiple solutions to this part of the problem. Although the lengths of the words are unique: (a, b, c, d) = (5, 6, 3, 8), there are two possible words with 3 letters giving the two solutions: MERRY WISHES GOD YULETIDE, and MERRY WISHES FOR YULETIDE. Although only one of these collections of words makes sense as a sentence.

[**] The published solution is “Merry wishes for Yuletide!”.