Enigmatic Code

Programming Enigma Puzzles

Puzzle 34: We compete. Who does what?

From New Scientist #1085, 12th January 1978 [link]

The jobs of my five employees, Alf, Bert, Charlie, Duggie and Ernie, have been changing rather frequently lately and I am afraid that I have got slightly out of touch. It was rather important for me, however, to find out who does what, as they had recently been having a test designed to find out more about their assorted capabilities and it was clearly important for the Managing Director to know just what had been happening in the past so that he could predict the future.

The information that I managed to get about their jobs and their places in the test (in which there were no ties) was as follows:

1. Bert was as many placed below the Worker as he was above the Door-Knob-Polisher.

2. The Door-Opener was three places above Charlie.

3. Alf’s place was even and the Door-Shutter’s place was odd.

4. The Bottle-Washer was two places above Ernie.

In what order did they come in the test, and what were their jobs?


Enigma 477: Gap ‘n enigma

From New Scientist #1628, 1st September 1988 [link]

In the following long multiplication I’ve replaced digits with letters in some places and left gaps in the rest. Where letters are used, different letters are used for different digits.

Enigma 477

That’s all you actually need, but to avoid hours of work I can also tell you that GAP is divisible by 9.

What is the value of IMPINGE?


Enigma 1034: Double-digit squares

From New Scientist #2190, 12th June 1999

Four of us were trying to find a one-digit perfect square, a two-digit perfect square, a three-digit perfect square and a four-digit perfect square, such that five different digits were each used twice to form them. To make matters harder for ourselves we agreed that one of those five digits must be 7. Since we remembered that both 0 and 1 are perfect square we were each able to chose a different one-digit square.

We each found a valid solution, and our solutions had no squares in common.

List in ascending order the other squares in the solution that had 9 as its one-digit square.


Tantalizer 440: Grunt

From New Scientist #991, 11th March 1976 [link]

Grunt is an after-shave lotion so maddening to women that the wearer can count on at least a broken leg in the rush. How curious then that some mad males are still using Phew. The makers of Grunt are so puzzled that the recently hired Judy the judo champion to look into it.

Judy soon discovered that she found both products equally repellant. So she decided she had better work scientifically. Boarding a strike-bound London bus, all of whose passengers were male, she set to with a questionnaire. Each passenger in turn informed her, “I am using Grunt myself. The man you have just asked is using Phew”. Each, that is, except the first man, who said only, “I am using Grunt”, but added afterwards, “The last man you asked is using Phew”.

Puzzled herself, Judy then asked a few selected passengers how many men were using Phew. The ugliest man said “19”, and then man she had originally interviewed next but three after him said “24”. The fattest said “13” and one she had originally interviewed next but four after him said “28”. The rudest said “24”, and the one she had originally interviewed next but five after him said “13”.

Given that each man used one of the other and that all and only those using Grunt told the truth, can you say how many were using Phew?


Enigma 476: A curious question

From New Scientist #1627, 25th August 1988 [link]

Kugelbaum wandered into a history lecture by mistake and, almost as quickly, but not by mistake, wandered out again. “1210 may well have been a dull year,” he said to himself, “but it’s an interesting number. The first digit gives the number of 0s in it, the next the number of 1s in it, the next the number 2s in it and so on, quite consistently, right up to the very last digit. And there are other such numbers too, such as 2020 and 3211000! Curiously, I can’t find one with six digits, though.”

As he sought vainly the room where he was to give his lecture on number theory he amused himself by calculating all the numbers having this property. “I wonder,” he remarked as he looked into broom cupboard, “if one were to take all the numbers having this property and add them together, what the result would be?”

What is the sum of all the numbers having the property that their first digit gives the number of 0s in the number, the next the number of 1s in the number, the next the number of 2s in the number and so on, consistently right through to and including the last digit of the number?

(Since 10, 11, 12 and so on are not digits, any such number containing more than 10 digits must have zeros in its 11th place and any other places after this).

Note: The original puzzle statement gave 211000 as an example, not 3211000.


Enigma 1035: Connected numbers

From New Scientist #2191, 19th June 1999 [link]

Take a large sheet of paper and write on it the numbers, 5, 6, 7, …, 999998, 999999, 1000000. You are now going to draw lines that connect pairs of the numbers as follows. Start with 5. Split 5 into two numbers, both larger than 1, in as many ways as you can. So 5 = 2 + 3. Multiply the two numbers together. Now 2 × 3 = 6, so draw a line connecting 5 and 6. The next number is 6. Now 6 = 2 + 4 = 3 + 3 and 2 × 4 = 8 and 3 × 3 = 9, so draw a line connecting 6 and 8 and another connecting 6 and 9. The next number is 7 = 2 + 5 = 3 + 4, and so we draw a line that connects 7 and 10 and another connecting 7 and 12.

Repeat the procedure for 8, 9, 10, …, in turn. Note that when a product is larger than 1000000 then no line is drawn, for example: 500002 = 2 + 500000 = 3 + 499999 = …, so a line is drawn connecting 500002 and 1000000 but no line is drawn for 3 × 499999 = 1499997.

1) When your diagram is complete, are there two numbers, both less than 250000, such that there is no path along the lines connecting one to the other?

Now for your second task, take another piece of paper. You want to write the numbers 5, 6, 7, …, 98, 99, 100 on it, and then copy onto it, from your first piece of paper, all the lines connecting numbers which are both less than or equal to 100.

2) Can you complete your second task in such a way that no two of the lines in fact cross?


Puzzle 35: Letters for digits — a multiplication

From New Scientist #1086, 19th January 1978 [link]

In the multiplication sum below the digits have been replaced by letters. The same letter stands for the same digit whenever it appears, and different letters stand for different digits.

Write the sum out with letters replaced by digits.


Enigma 475: Dance hall

From New Scientist #1626, 18th August 1988 [link]

At the dance there are 10 girls, Ann, Babs, Cath, Dot, Emma, Fay, Gwen, Hazel, Irene and Jane, and 10 boys. Jane knows one boy and Tom knows one girl, but I cannot tell you who they know. However, I can tell you all the other acquaintances:

Ken knows D, F;
Len knows E, H, I;
Mac knows B, F, G, I;
Ned knows A, B, H;
Owen knows E, G, I;
Pat knows A, B, C, D;
Quentin knows E, G;
Ray knows A, C;
Sam knows C, E.

The first dance pairs them off as follows:

Ann takes the hand of the first boy she knows, Ned (first always means first in alphabetical order), Babs does the same to Mac, then Cath, to Pat, then Dot, to Ken, then Emma, to Len. When Fay approaches Ken she finds he is holding Dot’s hand and the procedure becomes more complicated.

They form a line of the dance floor, F, K-D and ask the first boy who knows any girl on the floor to come out, bringing any girl that is holding his hand. The line becomes F, K-D, M-B. The procedure is repeated to give F, K-D, M-B, N-A. Repeating adds P-C to the line. Repeating again adds Ray to the line and the procedure stops as he has his hands free. The we have the line F, K-D, M-B, N-A, P-C, R.

Now Ray takes the hand of the girl he knows who is nearest to Fay in the line, Ann, and she releases Ned’s hand. Ned repeats the procedure Ray used and takes the hand of Babs who releases Mac. Mac repeated the procedure and takes the hand of Fay. That completes the pairing for Fay’s round.

The procedure is repeated for Gwen, Hazel, Irene, and Jane in turn. The pairing obtained after Jane’s round includes C-S, D-K, F-M, H-N and I-L.

Who do Jane and Tom know?

Note: I corrected a typo in the original puzzle while transcribing this (and I hope I didn’t introduce any more myself).


Enigma 1036: Multiple shifts

From New Scientist #2192, 26th June 1999 [link]

George’s young son has been playing with numbered cards and has discovered an interesting curiosity. Having placed six cards on the table to show the number 179487, he then moved the right-hand card to the left to form the number 717948. A quick check on his calculator confirmed that this number is exactly four times the first number.

George congratulated his son on this discovery, and then challenged him to find the smallest number which can be multiplied by four simply by moving the last digit to the front.

Can you find this number — and the smallest number that can be multiplied by five in similar fashion?


Tantalizer 441: Luck of the draw

From New Scientist #992, 18th March 1976 [link]

Dopey confessed that he had never learnt to play chess and was appointed umpire. The other six dwarves settled down to play a five-round tournament. Grumpy drew with everyone but Sneezy and finished equal bottom with Doc, whom he had played in the first round. Sneezy drew with Doc, Happy and Sleepy. Bashful drew with Sleepy. There were no other draws.

There was at least one draw in each round and each dwarf drew in at least two consecutive rounds. The two equal winners did not play each other in the second round.

What were the pairings in the final round?


Enigma 474: More goals

From New Scientist #1625, 11th August 1988 [link]

In this football league table, the sides are eventually going to play each other once, but, of the figures given, one is incorrect.

Enigma 474

(Two points are given for a win and one point to each site in a drawn match).

Which figure is wrong? What should it be? Find the score in each match.


Enigma 1037: The perfect shuffle

From New Scientist #2193, 3rd July 1999 [link]

I recently took an ordinary pack of playing cards and placed them on the table, face down. Somewhere in the pack the four aces were together, and in places further down the kings were together, the queens were together, and the jacks were together.

I then did the “perfect shuffle”. In other words I took the top 26 cards in my left hand, and the other 26 in my right, I flicked the bottom left-hand card on to the table, followed by the bottom right-hand card on top of it, followed by the next left on top of them, next right, next left, and so on. The cards remained face down at all times.

My fellow players were so impressed with this performance that I did three more perfect shuffles with the same pack. When I had finished, the arrangement of suits within the pack was exactly the same as when I started (for example, the top card was a heart before and after the four shuffles, the next was a spade before and after the four shuffles, and so on).

Counting from the top, what was the position of the ace of hearts after the four shuffles?


Puzzle 36: Football (4 teams: old method)

From New Scientist #1087, 26th January 1978 [link]

Four football teams — ABC and D — are all to play each other once. After some of the matches have been played a table giving some details of the number of matches played, won, lost etc. looked like this:

(2 points are given for a win and 1 point for a draw).

Find the score in each match.

A correction was published with Puzzle 39, as follows:

In the solution to Puzzle 36, the table should have shown that D played one match. The error is regretted.

I have made this change in the table above.


Enigma 473: Family ties

From New Scientist #1624, 4th August 1988 [link]

Eight players took part in a “round robin” chess tournament; that is, each player played each of the others exactly once. No game resulted in a draw. The players were four women and their husbands.

After the tournament, when each player had told me just the total number of games which he or she had won, it was possible to work out the results of all the games except those between Mr King and Mrs Bishop, Mr King and Mrs Castle, and Mrs Bishop and Mrs Castle.

The King couple won between them the same number of games as the Queen couple did. All the men won between them the same number of games as the women did. Two of the women were disappointed to have been beaten by both Mr King and Mr Bishop.

What were the results of the four games between married couples? (For example, Mr X beat Mrs X, Mrs Y beat Mr Y).


Enigma 1038: The running track

From New Scientist #2194, 10th July 1999 [link]

Bill takes five minutes to complete one lap of a circular running track, whereas Chad takes only four minutes. They set off together at the starting point and ran anti-clockwise. Before completing one lap, Chad reversed his direction of running. They stopped running when both of them happened to be at the start point at the same instant (for the first time after the start).

Given that they crossed each other five times while running, how long did Chad run anti-clockwise?


Tantalizer 442: What’s the score?

From New Scientist #993, 25th March 1976 [link]

The usual five football teams entered our local cup and played the usual one game against each of the others. Exactly three of the games were won by the home side. No two teams won the same number of games. There were no drawn games. Each team played two games at home.

The Ayfield Aces won two games. The Barnley Bears were at home to the Aces and to the Cornfield Casuals. The Casuals were at home to the Aces. Ditching Dynamos were at home to the Eggplant Eagles.

What was the result in each of the ten games?


Enigma 472: An omnidigital problem

From New Scientist #1623, 28th July 1988 [link]

“I have on a piece of paper,” said Ms Omnidigitalis to Mr Ffosby, “two proper fractions, F and f, not necessarily in their lowest terms. Of both F and f it is separately true that:

(a) Adding numerator to denominator gives 99999;
(b) Of the numerator and denominator, if one is not divisible without remainder by any of the numbers 2, 3, 4, 5, 6, 7, 8 or 9, then the other will be;
(c) The numerator and denominator between them use all the digits 0-9 once and once only;
(d) Neither the numerator nor the denominator begins with 0.”

“There must be about six such fractions,” remarked Ffosby. “Any more clues?”

“Yes. The numerator of F is double that of f.”

What is f in its lowest terms?

Enigma 1039: Mirror, mirror

From New Scientist #2195, 17th July 1999 [link]

George has fitted two mirrors inside a rectangular box, the first on one of the long sides, and the other across a diagonal. He shines a narrow beam of light through a small hole which he has drilled through the side of the box and the mirror on that side. It enters perpendicular to the side of the box, is reflected five times by the mirrors and emerges perpendicular to the end of the box through another hole, as shown.

The box is exactly one metre long. You can calculate the width if you wish, but that is not George’s problem. He wants to know how far the beam travels while it is inside the box.

Can you help him?


Puzzle 37: The bumbling B

 From New Scientist #1088, 2nd February 1978 [link]

On the Island of Imperfection there are three tribes, the Pukkas who always tell the truth, the Wotta Woppas, who never tell the truth, and the Shilli Shallas who make statements which are alternately true and false, or false and true.

This story deals with three inhabitants of the island, one from each tribe, whom we shall call AB and CA and C each make a statement, but B, who goes through life in a bumbling and idle sort of way, does not in fact say anything on this occasion, although of course when he does speak he conforms to the strict rules of his tribe.

A and C‘s statements are as following:

A: B is not a Wotta Woppa;
C: If I were to ask B what tribe A belonged to, he would, quite rightly, say Shilla Shalla.

To which tribes to AB and C belong?


Enigma 471: What you do is what you get

From New Scientist #1622, 21st July 1988 [link]

You are given the following four instructions:

A. Put the card in box 1 into box 2, put the card that was in box 2 into box 3, put the card that was in box 3 into box 4, and put the card that was in box 4 into box 1.
B. Exchange the cards in boxes 1 and 4, and exchange the cards in boxes 2 and 3.
C. Exchange the cards in boxes 1 and 2, and exchange the cards in boxes 3 and 4.
D. Exchange the cards in boxes 1 and 3, and exchange the cards in boxes 2 and 4.

If you wrote the four instructions in any order then you get a procedure, e.g. B, C, A, D. The procedure is applied to four boxes numbered 1, 2, 3, 4, which initially contain cards labelled A, B, C, D, respectively.

To apply the procedure, simply obey the instructions in the selected order, e.g. for order B, C, A, D, we obey B to get D in 1, C in 2, B in 3, A in 4, then obey C to get C in 1, D in 2, A in 3, B in 4, then obey A to get B in 1, C in 2, D in 3, A in 4, and finally obey D to get D in 1, A in 2, B in 3, C in 4. This instruction order B, C, A, D produces final card order D, A, B, C.

Which instruction order produces a final card order which is the same as that instruction order?