Enigmatic Code

Programming Enigma Puzzles

Tag Archives: by: Christophe Maslanka

Enigma 407: Bug-in-a-box

From New Scientist #1557, 23rd April 1987 [link]

A collector was ordering a thin rectangular box to house insects captured in the field.

“Each of its edges must measure a whole number of inches”, he told the carpenter.

“Well, that leaves a lot of room for manoeuvre”, the other remarked.

“That’s exactly the point”, the collector said. “You see, they cling to the edges of the box for security, poor little mites, and they detest traversing the same edge twice … But though they are confined to the edges they can still dream of unconquerable space. In fact I don’t know which is more important, the volume or the length of the edges. You’d better make the volume in cubic inches equal to the sum of all the 12 edges of the box”.

“Well, that narrows is down a little”, said the carpenter.

“Oh dear, I hope not”, said the collector. “Please make it as big as you can consistent with these specifications”. So saying he rushed out, almost snagging his net on the door handle.

The carpenter produced the box just as he was bidden. Assuming bugs do refuse to traverse any part of an edge previously trodden by them, what is the furthest a captive bug can walk before it becomes bored?


Enigma 403: Taking stock

From New Scientist #1553, 26th March 1987 [link]

“What animals have you in that barn there?” said the man from the ministry.

The farmer beamed. “Pigs, cows and ducks, sir.”

“How many are there, though?”

“Oh, quite a few, really, sir.”

“I need figures, man!” persevered the would-be census taker.

“If it’s figures you’ll be wanting, sir,” replied the farmer, “I can tell you that multiplying the number of horns by the number of legs by the number of wings gives 720.”

“Yes, but how many of each animal are there?” snapped the other exasperatedly.

“Telling you the number of cows alone wouldn’t enable you to deduce the number of ducks and pigs. Telling you the number of ducks alone wouldn’t enable you to deduce the number of pigs and cows. But telling you the number of pigs would enable you to deduce the number of cows and ducks right enough. So I reckon you can work out how many cows and ducks there be in yonder barn even if I don’t tell you the number of pigs in it.”

With that he ducked into a hen-house.

How many cows, ducks and pigs were there in the barn?


Enigma 400: Potential difficulties

From New Scientist #1550, 5th March 1987 [link]

I asked Electrophorus what he was working on.

“You know that joining unlike terminals of a pair of batteries produces a voltage across the two free terminals equal to the sum of the voltages of the separate batteries. And connecting unlike terminals produces a voltage equal to the difference of the voltages of the separate batteries?”

“Yes”, I replied. “With a battery of 2 volts and one of 5 volts one obtains 3 volts (sources opposing) or 7 volts (sources reinforcing).”

“Well, before lunch I had three batteries, none of which had zero voltage, and a voltmeter with a holder that would accommodate only two batteries. So I measured the voltages across the free terminals of all possible pairwise combination of these three batteries both in the case where the voltages reinforced and where they opposed. I wrote on my blackboard the resulting six positive numbers in order of increasing magnitude.”

“When I returned from lunch eager to calculate the ratings of the three batteries, I found the three batteries gone and my blackboard wiped clean. I remember that the second smallest reading occurred twice. It was either 13 or 17 volts, I forget which. I had noticed, rather inconsequentially perhaps, that reversing the digits of this double reading produced another reading which occurred in my measurements.”

What were the ratings of the three batteries?


Enigma 394: Unwinding

From New Scientist #1544, 22nd January 1987 [link]

Professor Kugelbaum was unwinding at the Maths Club with a cigar after lunch when a wild-looking man burst in and introduced himself thus:

“My name is TED MARGIN. Juggling with the letters of my name one obtains both GREAT MIND and GRAND TIME. But I digress. Each letter of my name stands for one digit exactly from 1 to 9 inclusive and vice versa. And, do you know,

(A × R × M) / (A + R + M) = 2,

MAD is greater than ART (though RAT is greater than either), and TED = MAR + GIN.

If, in addition, I were to tell you the digit which corresponds to M then you could deduce the one-to-one correspondence between the letters of my name and the digits 1 to 9″.

At this point a helpful butler removed the man, but Kugelbaum was amused to find that the information was quite consistent.

Write the digits 1 to 9 in the alphabetical order of the letters to which they correspond.


Enigma 391b: Christmas recounted

From New Scientist #1540, 25th December 1986 [link]

Delivering Christmas presents is not an easy task and Exe-on-Wye has grown to be so populous that it is hardly surprising that this year Santa Claus decided to delegate the delivery to his minions. Thanks to some failure in communication, however, instead of each house receiving one sack of presents, each of his helpers left a sack at each and every house. The number of sacks that should have been delivered happens to be the number obtained by striking out the first digit of the number of sacks delivered.

When Santa Claus discovered this, he was not pleased. “Things couldn’t be worse!” he groaned. “The number of sacks you should have delivered is the largest number not ending in zero to which the addition of a single digit at the beginning produces a multiple of that number”. And he disciplined the unhappy helpers.

But for each unhappy helper there were many happy households in Exe-on-Wye on Christmas morning.

Can you say how many unhappy helpers and how many happy households?

This puzzle completes the archive of Enigma puzzles from 1986, and brings the total number of Enigma puzzles on the site to 1,058. There is a complete archive from the start of Enigma in February 1979 to the end of 1986, as well as a complete archive from February 2001 to the end of Enigma in December 2013, which is 59% of all Enigma puzzles, and leaves 733 Enigma puzzles left to publish.

I have also started to post the Tantalizer and Puzzle problems that were precursors to the Enigma puzzles in New Scientist, and so far I have posted 16 of each. In total there are 90 Puzzles (which I can get from Google Books) and 500 Tantalizer puzzles (of which the final 320 are available in Google Books).

Happy puzzling (and coding)!

[enigma391b] [enigma391]

Enigma 387: Tea for two

From New Scientist #1536, 27th November 1986 [link]

The Emperor decided to reward two philosophers, who, despite their widely different lifestyles, had never disagreed in the whole of their careers. Their reward was explained to them as follows:

“You, Ti-Fu-Tu, poet and hedonist, drink jasmine tea, while you, Tu-Fu-Ti, old warrior and ascetic that you are, drink only gunpowder tea. In my storehouse are vast numbers of identical cubical boxes of both teas. You may take as many boxes as you will as long as you stack them thus:

The stack must form a singular rectangular parallelepiped consisting of equal numbers of boxes of jasmine and gunpowder. The surface of the stack on all its six sides must be a single layer of boxes of jasmine. Within this single layer must be a rectangular parallelepiped of gunpowder tea. Of course, the boxes must be stacked face-to-face with no gaps.

“A stack of 960 boxes, measuring 8 by 10 by 12 should answer,” reasoned Tu-Fu-Ti. “Stripping off the outer layer would reveal a stack measuring 6 by 8 by 10 containing 480 boxes of beloved gunpowder.”

“Tchah!” snapped Ti-Fu-Tu. “I’m sure we can do better than that!”

Can you tell them (before they squabble and forfeit their reward) the number of boxes they would each have if they produce the largest stack obeying the above conditions?


Enigma 382: Dice

From New Scientist #1531, 23rd October 1986 [link]

While rummaging through the library stacks I found a Latin manuscript which translates roughly as follows:

Dear Uncle,

The natives in these desert parts use tetrahedral dice, rather than the cubical ones of Rome; a tetrahedral die sticks into the sand point first, which is useful when there are no pavements to play on. Each face on a given die is numbered with a different natural number (being nomads they count zero as a natural number). A set consists of two dice numbered in such a way that no score with a single die or with a set is a power of two, apart from the highest score possible with a pair. (In case you are rusty, Uncle, 1 is counted as a power of 2). What’s more, you can’t throw a total of zero with a set. Every other score up to the highest can be thrown with a pair.

I won’t bore you with an account of my losses, but I am told that the information given is sufficient to determine the numbers on each of the two dice.



What numbers are inscribed on the two dice?


Enigma 378: A sleeper awakes

From New Scientist #1527, 25th September 1986 [link]

I fell asleep during a lecture and dreamed that I was out in the country. In my dream I saw a field and in this field some four-legged cows being milked by at least one two-legged milkmaid who had the use of a number of three-legged stools. There were more stools than would suffice for one per milkmaid, and more cows than would suffice for one per milking stool.

Given this information, and the number of legs in the collection, I realised that one could work out unambiguously the number of cows, stools and milkmaids in the field. Furthermore, the number of legs in the field was the largest it could have been, consistent with these facts.

I awoke with quite a start when the lecturer addressed a question to me. Unfortunately, the answer I gave to his question was the number of cows, milking stools and milkmaids that I had dreamed of. Of course, everyone laughed, but I bet they wouldn’t be able to solve that in their sleep!

How many milkmaids were there in my dream, and how many milking stools and cows?


Enigma 374: Just the ticket

From New Scientist #1523, 28th August 1986 [link]

Mr Bagel was intrigued when approached by Mr Bola selling raffle tickets, for he had never taken part in a raffle.

“I see that each ticket in your book has the same number of digits on it, the first having a number of zeros followed by a one, and the number on each successive ticket increasing by one.”

“That’s true,” replied Bola. “I haven’t sold any yet. Perhaps that’s because there is to be only one winning ticket.”

“Now tell me, Tom,” asked Bagel, “what happens if a ticket number is composed entirely of invertible digits, namely 0, 1, 8, 6 or 9, so that is also forms a number when viewed upside down?”

“In a draw we always read the tickets out with the perforation on the left,” replied Bola.

“That’s a pity, otherwise one could buy two numbers for the price of one ticket.”

Bagel, being superstitious, chose a ticket with an invertible number. One way up the number was divisible by all the even digits, and the other way up it was divisible by all the odd digits. Moreover, when his ticket number was multiplied by a digit (I forget which), the product was the number of the last ticket in the book, a number in which none of the digits was invertible.

I forget whether he won the draw, or even what the draw was for. But, given the chances of his winning were better than one in 100,000, what was the number on the last ticket in the book?


Enigma 369: A safe number

From New Scientist #1518, 24th July 1986 [link]

“My memory is poor, but accurate,” said Mooncalf. “I remember just enough of the characteristics of my safe combination to enable me to reconstruct the number when I forget it. It contains a pair of 1s separated by one digit, a pair of 2s separated by two digits, a pair of 3s separated by three digits and so on, there being twice as many digits in the number as the value of the highest digit. Yet I can’t even remember the highest pair of digits.”

“There must be many such numbers,” I opined, reaching for my notepad. “For example, 312132. That has two 1s separated by one digit, two 2s separated by two digits and two 3s separated by three digits.”

“Yes. But what makes my safe number unique is that it is the highest number that can be formed in this way. As an aide-mémoire, I have written part of it on a card. If anyone stumbles across it he is unlikely to tumble to its true significance. First I write the safe number backwards. Then, starting from the right I discard from this number, one by one, as many digits as I can, consistent with there occurring at least once in the number which remains each digit of the original number. This final number is my aide-mémoire.”

“You mean if it were 41312432 you would be left with 23421 on the card?”

“Exactly. But I have locked it away in the safe, and I want you to help me to deduce my combination so I can open the safe and retrieve it.”

Scratching my head, I got down to work. In no time at all I had deduced the number and had retrieved Mooncalf’s card.

What was the number inscribed on it?


Enigma 365: Men of letters

From New Scientist #1514, 26th June 1986 [link]

Six Professors, A, B, C, D, E and F, are the guest speakers at a philosophy conference at St Gadarene’s. So that they should not be confused with the audience they are given labels A, B, C, D, E and F by the organisers. Unfortunately, none of them ended up with the right label. On the way up to the podium, Professor A asks the man wearing the letter B: “Are you Professor C?”

“No. Why do you ask? You’re not wearing C. But Professor C ought to swap labels with Professor F, for then one of them would have the right label. And in case you were wondering, I’m not D either.”

“I’ve never seen such disarray. It would be quite impossible to choose a single pair from the six of us in such a way that one of the two might truthfully say to the other: ‘We two have each other’s labels’.”

“Well, it could be worse. At least the company can be divided into two groups, each of which would sport the same letters as the professors it contains. What’s more, each group would have a label with a vowel on it. Now please leave me alone, I’m a solipsist.”

By this time the applause had died down and it was decided that the professors should present their papers in the alphabetical order of the labels they each wore.

I wasn’t too happy with the paper about utilitarianism. I enjoyed “Why pragmatism doesn’t work”. But most of all I enjoyed deducing the names of the professors from their labels.

Can you list the names of the six professors in the order in which they presented their papers?


Enigma 360: For the time boing

From New Scientist #1509, 22nd May 1986 [link]

“This is my favourite clock,” said Mr Fescu, the Curator of the House of Clocks. “It has a curious mechanism which prevents it from stopping or being started except exactly on the hour. It only chimes on the hour and normally emits a number of bongs equal to the hour it is striking. But if it stops and is restarted at a later hour less than 12 hours on it emits all the chimes it missed between the stopping and starting times, not counting those of the hour at which it is restarted.”

“You mean if it stops at 9:00 and is restarted at 8:00 it emits 70 bongs?”

“Precisely,” said my guide, clutching and enormous key. “And what is more interesting is that certain numbers of bongs are special, in that they occur between one unique pair of stopping and starting times only. If you heard 70 bongs it could only signify that the clock stopped at 9:00 and was restarted at 8:00. Given the time at which the clock has stopped this time, there is only one hour at which I could rewind it to yield a magic number of bongs, and Lo!” he said, hopping from foot to foot and gesticulating at the church clock just visible in the distance, “that hour is arrived.”

So saying he moved the hands to the right time, wound the mechanism up and kicked it, whereupon it emitted an uneven number of bongs and a prime number at that.

What was the time; when had the clock stopped; how many bongs did the clock emit?


Enigma 356: Counting house

From New Scientist #1505, 24th April 1986 [link]

“My fortune,” said the king to his vizier, “consists of a number of identical gold pieces. I remember their number by a set of peculiar numerical circumstances. I do not speak their number openly, as there are spies and eavesdroppers at court. Instead I shall tell you indirectly.”

“My fortune cannot be divided equally among my sons without splitting gold pieces. Nor could it be so divisible, unless the number of my sons were to run into thousands. My three youngest sons live in the palace, and of the other 15 some have perished in the late wars against the heathen.”

“Now the number of pieces of gold in my fortune has the following curious property: if one multiplies it by the number of my sons living, one obtained a 10-digit number in which all the digits from 0 to 9 appear, with one exception. If any number of digits be cut off the right of this number, the remaining digits form a number which is divisible without remainder by the number of digits cut off. You have a reputation of being a calculator, and so will know the number I mean, and thus the number of gold pieces in my counting house.”

The vizier bowed and reached for his pen case and parchment.

How many sons and how many gold pieces did the king possess?


Enigma 352: In the bag

From New Scientist #1501, 27th March 1986 [link]

Yesterday, I was presented with an unusual box containing 13 painted Easter eggs. Each egg was either red, white or blue and there was at least one egg of each colour. If I had been in a dark room, the minimum number of eggs I would have had to withdraw from the box to be certain of picking at least three eggs of the same colour was the same as the number of blue eggs in the box.

Being superstitious, I decided against leaving 13 eggs in the box and transferred a number to a black bag. This bag may not have been empty before I added the coloured eggs. If it wasn’t, then it contained one or more black eggs and nothing else. However, two things are certain. One is that if I were in a dark room, the minimum number of eggs I would now have to withdraw from the box to be sure of having at least three eggs of the same colour is the same as the number of blue eggs in the bag. The second is that the chances of picking out a white egg from the bag with one attempt are the same as the chances of picking out a white egg from the box with one attempt.

But I am in a dark room. Trying to deduce the contents of that black back without turning the light on and looking is keeping me awake late into the night.

How many red, white, blue and black (if any) eggs are there in the bag?


Enigma 348: A piece of cake

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?


Enigma 343: In the mews

From New Scientist #1492, 23rd January 1986 [link]

Silent Mews, the cul-de-sac where I live, is dull and uniform. Every house on this side of the road has one exactly corresponding to it on the other side, and vice versa. The only exciting thing about it is that the houses are numbered boustrophedon. That is, starting at number 1 and visiting each house in numerical order takes you up one side of the street, along the end of the mews and back along the other side.

To lend my house individuality, I have bought brass numbers for my front door (all the other houses have plastic). Each digit costs the same, so it would cost 222 times what I paid for my door number to replace everyone else’s door numbers with brass. Not only does my property have a special number, but my number has a special property. Rearranging its digits produces exactly four numbers. One of these is my number and one is the number of another house in the mews.

If more houses were to be added on after the last house on the mews, it it would be possible for the set of digits in my number to be the only set which appeared in a total of exactly four house numbers, two of which were in the old part of the mews, and two which appeared in the newly extended part.

You may wonder whether, besides the houses on the two long sides of the mews, there are also houses at the blind end of the mews, but the answer to this should be obvious, as is the answer to this puzzle, namely: what is the number of the house directly opposite mine?

I am going to be away next week, but I will try and keep to the posting schedule if possible.


Enigma 337: Chock-a-block

From New Scientist #1485, 5th December 1985 [link]

I was visiting my Uncle Ever-Clever, the inventor. “What are all these little cubes and boxes?” I asked. “Ah,” he said, “that’s a mathematical game I’ve been working on involving cubelets, each of whose faces is either black or white. I realised that I’d have my work cut out making each cubelet individually, so I hit upon the idea of taking a large cube of black wood and an equal cube of white wood, then painting the black one white and the white one black.”

“How would that help?” I asked woodenly.

“Well, when you saw them up you obtain cubelets having various combinations of white and black faces. Every distinguishable combination of black faces and white faces manufacturable by these means occurs exactly once in a complete set of my Chock-a-Block cubes.

“And do all-white and all-black each count as combinations?” I asked.

“Of course, you blockhead!” was the affectionate replay as he closed the Brewster window (he suffered from sunspots).

“Well, I transformed the two painted cubes without wastage of wood into equal cubelets in such a way that, when they were sorted into complete sets, the amount of wood left over was the minimum possible. These boxes each contain a full set of my cubelets; those over there between the Wimshurst bicycle and the Luminous Moondial are the ones left over… But you must be famished, dear boy; let me ring for a pot of Logwood Tea and some Dwarfstar Cake.”

How many boxes were there, how many cubelets did they each contain and how many cubelets were left over?


Enigma 323: A man of letters

From New Scientist #1471, 29th August 1985 [link]

Professor D. O’Phantus does all his calculations in code, with each digit represented by a letter of the alphabet. Each letter always stands for the same digit and each digit is always represented by the same letter. At the end of one of his confusing lectures on “Letter Theory” some examples of calculation remained on the blackboard.

According to the professor:

Enigma 323 - 1

Sadly, the result of another addition:

Enigma 323 - 2

had been wiped out, but when it was multiplied by the result of the previous sum it apparently yielded OMTTOUI.

“This is quite hopeless”, said Magnus Swottus. “How can we do lots of lovely homework if we don’t know what the letters stand for? It might as well be Greek.”

But Goody-Goody Major, unwilling to be done out of his homework, was more philosophical. “We’ll just have to crack old Doodah’s code, and then just think of all the problems open to us? We’ll even be able to invent our own!”

Can you help these young enthusiasts by writing out in order the letters corresponding to the digits from 0 to 9?