Enigmatic Code

Programming Enigma Puzzles

Enigma 432: Holiday on the islands

From New Scientist #1582, 15th October 1987 [link]

Alan and Susan recently spent eight days among the six Oa-Oa islands, which are shown on the map as Os.

Enigma 432

Only two of the islands, Moa-Moa and Noa-Noa, have names and hotels. The lines indicate the routes of the four arlines: Airways, Byair, Smoothflight and Transocean.

Alan and Susan started their holiday on the morning of the first day on Moa-Moa or Noa-Noa. On each of the eight days they would fly out to an unnamed island in the morning and then on to a named island in the afternoon and spend the night on that island. They each had eight airline tickets and each ticket was a single one-island-to-the next journey for two passengers. Alan had two Airways and six Byair tickets, while Susan had three Smoothflight and five Transocean tickets. They noticed that whatever island they were on, only one of them would have tickets for the flights out and so they agreed that, each time, that person should choose which airline to use.

Now Alan preferred that they should spend the nights on Moa-Moa, while Susan preferred Noa-Noa. However, they are an inseparable couple. So they each worked out the best strategy for the use of their tickets in order to spend the maximum number of nights on their favourite island.

How many nights did they spend on each island?



Tantalizer 463: Benchwork

From New Scientist #1014, 19th August 1976 [link]

The notice in the magistrates retiring room at Bulchester court reads baldly, “Monday: Smith, Brown, Robinson”. These are the surnames of next Monday’s bench, which will, as always, include at least one man and one married woman. All male magistrates at Bulchester happen to be married. These facts are known to all magistrates.

The court being a large and new amalgamation, Smith, Brown and Robinson know nothing about each other. But Smith, on being told the sex of Brown, could deduce the sex of Robinson and the marital status of both. And Robinson, being told only that Smith could do this, could deduce the sex and marital status of Smith and Brown.

What can you deduce about the trio?


Enigma 1079: Girls’ talk

From New Scientist #2235, 22nd April 2000

One of the three girls Angie, Bianca and Cindy always tells the truth, one always lies, and the other is unreliable in the sense that a true statement is always followed by a false one and vice versa. Here are some things they just said about themselves:

Angie: The eldest is dishonest. The tallest is unreliable.
Bianca: The youngest is honest. The shortest is unreliable. Angie is taller than me.
Cindy: The youngest is unreliable. The tallest is honest.

What are Cindy’s characteristics? (For example – honest, youngest and mid-height).


Enigma 431: Error in the code

From New Scientist #1581, 8th October 1987 [link]

In the addition sum below, letters have been substituted for digits. It was Uncle Bungle’s intention, when he made this sum up, that the same letter should stand for the same digit wherever it appeared, and that different letters should stand for different digits. Unfortunately, however, he made a mistake, and one of the letters is incorrect.

Write out the correct sum with digits substituted for letters.


Puzzle 57: Football letters for digits

From New Scientist #1108, 22nd June 1978 [link]

Four football teams (ABC and D) are to play each other once. After some of the matches had been played a table giving some details of the numbers won, lost, drawn, and so on was drawn up.

But unfortunately the digits have been replaced by letters. Each letter stands for the same digit (from 0 to 9) whenever it appears and different letters stand for different digits.

The table looks like this:

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

Find the score in each match.


Enigma 1080: Magic product

From New Scientist #2236, 29th April 2000

A magic square consists of a 3 × 3 array of nine different integers, nought or more, such that the sum of each row, column and main diagonal is the same. The most familiar one is:

If you form the product of each row and add them up you get 8×1×6 + 3×5×7 + 4×9×2 = 225. Similarly if you form the product of each column and add them up you get 8×3×4 + 1×5×9 + 6×7×2 = 225. Remarkably the two numbers will be equal for any magic square, and it is known as the “magic product”.

There is a magic square whose middle entry is a single digit number which equals the sum of the three digits in its magic product.

What is that magic product?


Enigma 430: Let your fingers do the walking

From New Scientist #1580, 1st October 1987 [link]

Enigma 430

My Welsh friend, Dai the dial, has a telephone number consisting of nine different digits and, as you telephone him on my push-button phone illustrated above, you push a sequence of buttons each adjacent (across or down) to the one before.

The digit not used in his number is odd, the last digit of the number is larger than the first, and (ignoring the leading digit if it is zero) the number is divisible by 21.

What is Dai’s number?


Tantalizer 464: Pentathlon

From New Scientist #1015, 26th August 1976 [link]

The Pentathlon at the West Wessex Olympics is a Monday-to-Friday affair with a different event each day. Entrants specify which day they would prefer for which event — a silly idea, as they never agree.

This time, for instance, there were five entrants. Each handed in a list of events in his preferred order. No day was picked for any event by more than two entrants. Swimming was the only event which no one wished to tackle on the Monday. For the Tuesday there was just one request for horse-riding, just one for fencing and just one for swimming. For the Wednesday there were two bids for cross-country running and two for pistol-shooting. For the Thursday two entrants proposed cross-country and just one wanted horse-riding. The Friday was more sought after for swimming than for fencing.

Still, the organisers did manage to find an order which gave each entrant exactly two events on the day he had wanted them.

In what order were the events held?

I don’t think there is a solution to this puzzle as it is presented. Instead I would change the condition for Thursday to:

For Thursday two entrants proposed cross-country and just one wanted fencing.

This allows you to arrive at the published answer.


Enigma 1081: Prime cuts

From New Scientist #2237, 6th May 2000

My supermarket was offering a discount of £2 off the cost of shopping if the bill exceeded a certain number of pounds. I qualified for the discount though my bill exceeded the minimum required for it by less than £1. My bill, both before and after the discount was applied, was for a prime number of pence.

The same discount offer applied the following week and everything stated above was again true of my new bill. Over the two weeks the total cost of my shopping was an exact number of pounds, prime whether or not you take the discounts into account and less than £30.

How much did each of my two bills amount to before the discounts were applied? Remember, there are 100 pence in a pound.


2017 in review

Happy New Year from Enigmatic Code!

There are now 1,134 Enigma puzzles on the site, along with 35 from the Tantalizer series and 34 from the Puzzle series (and a few other puzzles that have caught my eye). There is a complete archive of Enigma puzzles published between January 1979 to September 1987, and from May 2000 up to the final Enigma puzzle in December 2013, which make up about 63.3% of all the Enigma puzzles published. Of the remaining 654 puzzles I have 152 left to source (numbers 891 – 1042).

In 2017, 105 Enigma puzzles were added to the site (and 30 Tantalizers and 28 Puzzles, so 163 puzzles in total). Here is my selection of the puzzles that I found most interesting to solve over the year:

Older Puzzles (1986 – 1987)

Newer Puzzles (2000 – 2001)

Other Puzzles

I have continued to maintain the enigma.py library of useful routines for puzzle solving. In particular the SubstitutedExpression() solver and Primes() class have increased functionality, and I have added the ability to execute run files, in cases where a complete program is not required. The SubstitutedDivision() solver is now derived directly from the SubstitutedExpression() solver, and is generally faster and more functional than the previous implementation.

I’ve also starting putting my Python solutions up on repl.it, where you can execute the code without having to install a Python environment, and you can make changes to my code or write your own programs (but a free login is required if you want to save them).

Thanks to everyone who has contributed to the site in 2017, either by adding their own solutions (programmatic or analytical), insights or questions, or by helping me source puzzles from back-issues of New Scientist.

Enigma 429: Professor Quark

From New Scientist #1579, 24th September 1987 [link]

Professor Quark was standing in a queue at a cheese counter. “I seem to be in a rather stationary state,” he mused out loud. “This queue and my position in it have a special property. You see,” he explained to an imaginary observer, “if one person were to drop out of the queue ahead of me, the number obtained by dividing the number behind me by the number remaining ahead would be an integer or half an integer. If instead a person were to drop out of the queue behind me, then number obtained by dividing the number ahead of me by the number remaining in the queue behind me would also be either and integer of half an integer.”

Bearing in mind that a queue with, say, 3 in front and 4 behind is distinguishable from one with 3 behind and 4 in front, and assuming Quark’s calculations were correct:

(a) How many distinguishable queues satisfy Quark’s observation?

(b) What was the largest number of people, including Quark, that there could have been in the queue?


Puzzle 58: Letters for digits

From New Scientist #1109, 29th June 1978 [link]

In the following division sum each letter stands for a different digit. Rewrite the sum with the letters replaced by digits.


Enigma 1082: End-of-season blues

From New Scientist #2238, 13th May 2000

In 1998-99 our local hockey team had 5 teams, Ant, Bat, Cat, Dog and Emu. Each team played every other team once during the season. There were no drawn games as penalty shoot-outs were used when required. One point was awarded for a win. At the end of the season the teams were ordered in a table according to points and teams with equal points were bracketed together. The only game I saw was when Cat beat Dog. The final game of the season was Ant versus Bat. Unfortunately, before it was played it was clear that whatever the result of the game, it was going to have no effect on the order and bracketing of the teams in the end-of-season table.

Question 1. Who won the game between Cat and Emu?

In 1999-00 the number of teams went up to 7 with the addition of Fox and Gnu. The rules were not changed. I remember that Bat beat both Cat and Dog; however Bat finished the season with fewer points than Ant. The final game of the season was again Ant versus Bat and again it was clear beforehand that the result would have no effect on the order and bracketing of the table.

Question 2. How many points did Emu have at the end of the season and who won the games Cat v Fox and Dog v Gnu?

Happy Christmas from Enigmatic Code!


Enigma 428: The torn map

From New Scientist #1578, 17th September 1987 [link]

Nostalgia Pictures are remaking that old Saturday matinée movie serial The Torn Map. This tells how the heroine searches for the map which will reveal the whereabouts of the treasure she has inherited. The map has been torn into 12 parts, and she retrieves one part in each episode of the serial. Incidentally, you might recall the titles of those episodes: “Trail of the map”, “Flames of death”, “Avalanche horror”, “Beneath thundering hooves”, “Lift-shaft terror”, “Poison peril”, “Cliffs of doom”, “Snakes of menace”, “Plunge to disaster”, “Bombs of vengeance”, “Crash of danger”, “Secret of the map”.

In the final episode the heroine has the 12 numbered pieces on the table in front of her. To her horror, she finds that each piece had part of the real map on one side and part of a fake map on the other. Thus she will have to turn some of the pieces over so that all 12 real parts are face up. To help her, each piece has some letters on each side. For example, piece 5 has F on the face-up side, and I and E on the face-down side. If she can turn over some of the pieces so that every letter in the alphabet from A to O is showing face-up, then she will have the 12 real parts of the map showing.

The letters on the pieces are as follows, with letters on the face-up side given first, and then those on the face-down side:

(1) C/H;
(2) G/N;
(3) D/F;
(4) J/G;
(5) F/I,E;
(6) B/L,H;
(7) I/E,D;
(8) A/KO;
(9) B/M,E;
(10) O,N/K;
(11) M,L/C;
(12) B,N/A.

Which pieces should she turn over?


Tantalizer 465: Decline and fall

From New Scientist #1016, 2nd September 1976 [link]

Paul Pennyfeather, you will recall from Evelyn Waugh’s novel, was sent down from Oxford and went to teach in Dr Fagan’s horrid school at Llanaba Abbey. There he found that a class of the beastliest boys could be kept quiet till break by offering a prize of half a crown for the longest essay, irrespective of all possible merit. Now read on:

“Sir”, remarked Clutterbuck after break, “I claim the prize”.

“But you”, Paul protested feebly, “have written only one-third as many words as Ponsonby, one-fifth as many as Briggs and one-eighth as many as Tangent”.

“Nonetheless, Sir, Dr Fagan would certainly wish me to have the prize”.

And so it proved. You might also like to know that the oldest of these four boys wrote 2222 more words than the second oldest and used more full stops in his essay than any of them who wrote less words than the youngest.

Where was Clutterbuck in the order of age, and how many words did he write?


Enigma 1083: Trios of semi-primes

From New Scientist #2239, 20th May 2000

A semi-prime is the product of two prime numbers. Harry, Tom and I each chose a set of three two-digit semi-primes which formed an arithmetic progression, such that the six factors of the three semi-primes in any one set were all different. The first (lowest) number in each of our sets was identical.

We then each chose another such set. This time the middle number in each of our sets was identical.

We then each chose another such set. This time the last (highest) number in each of our sets was identical, and of the other two semi-primes in my set one also appeared in Harry’s set and the other also appeared in Tom’s set.

The nine sets that we chose between us were all different, but one semi-prime appeared in all three sets that I chose.

List the three sets that I chose in the order in which I chose them, with the numbers in each set in ascending order.


Enigma 427: Settle some new scores

From New Scientist #1577, 10th September 1987 [link]

Football teams A, B, C and D are having a competition against each other, under a new method which has recently become popular. Under this method, 10 points are awarded for a win, 5 points for a draw, and 1 point for each goal scored. The situation when all but one of the matches had been played was as follows:

A, 9 points; B, 2 points; C, 24 points; D, 34 points.

Each side scored at least one goal in every match, but not more than seven goals were scored in any match.

Find the score in each game.


Puzzle 59: Cricket

From New Scientist #1110, 6th July 1978 [link]

ABC and D are having a cricket competition with each other in which eventually there are all going to play each other once. Points are awarded as follows:

To the side that wins: 10
To the side that wins on the first innings in a drawn match: 6
To the side that loses on the first innings in a drawn match: 2
To each side for a tie: 5
To the side that loses: 0

The latest news I have about their points is as follows:

21; 10; 9; 6.

Find the result of each match.


Enigma 426: Time and again

From New Scientist #1576, 3rd September 1987 [link]

Time and again, you’ve been asked to sort out letters-for-digits puzzles, where digits are consistently replaced by letters, different letters being used for different digits. Today, that recurring theme is used in a truly recurring way. The fraction on the left (which is in its simplest form) represents the recurring decimal on the right. Should you want an extra optional clue, I can also tell you that the last two digits of the numerator of the fraction are equal.

Enigma 426

What is AGAIN?


Enigma 1084: 1-2-3 triangles

From New Scientist #2240, 27th May 2000

The diagram shows a large triangle divided into 100 small triangles. There are 66 points that are corners of the small triangles.

You are to write 1 or 2 or 3 against each of the 66 corner points. The only restrictions are:

(a) the corners of the large triangle must be labelled 1, 2 and 3 in some order;
(b) each number on a side of the large triangle must be the same as the number at one end of that side.

Q1: Is it possible for you to write the numbers on so that there are precisely 10 small triangles with corners labelled 1, 2 and 3?

Q2: As Q1 but with 32 small triangles.

Q3: As Q1 but with 61 small triangles.

Q4: As Q1 but with 89 small triangles.