### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,314)
- misc (3)
- project euler (2)
- puzzle (78)
- puzzle# (21)
- site news (54)
- tantalizer (80)
- teaser (7)

### Site Stats

- 217,165 hits

Programming Enigma Puzzles

2 August 2019

Posted by on **From New Scientist #2154, 3rd October 1998** [link]

To celebrate next week’s 1000th edition of

Enigma, we each made up an Enigma. Each one consisted of four clues leading to its own unique positive whole number answer. In each case none of the four clues was redundant. To avoid duplication, Keith made up his Enigma first and showed it to Susan before she made up hers.The two Enigmas were meant to be printed side-by-side but the publishers have made a (rare) error and printed the clues in a string:

(A) It is a three-figure number;

(B) It is less than a thousand;

(C) It is a perfect square;

(D) It is a perfect cube;

(E) It has no repeated digits;

(F) The sum of its digits is a perfect square;

(G) The sum of its digits is a perfect cube;

(H) The sum of all the digits which are odd in Keith’s answer is the same as the sum of all the digits which are odd in Susan’s.Which four clues should have formed Keith’s Enigma, and what was the answer to Susan’s?

There are now 1300 *Enigma* puzzles available on the site (or at least 1300 posts in the *enigma* category). There are 492 *Enigma* puzzles remaining to post.

There are currently also 76 puzzles from the *Tantalizer* series, 75 from the *Puzzle* series and 13 from the new *Puzzle #* series of puzzles that have been published in *New Scientist* which together cover puzzles from 1975 to 2019 (albeit with some gaps).

I also notice that the **enigma.py** library is now 10 years old (according to the header in the file – the creation date given coincides with me buying a book on *Python*). In those 10 years it has grown considerably, in both functionality and size. I’m considering doing a few articles focussed on specific functionality that is available in the library.

[enigma999]

%d bloggers like this:

None of the statements are redundant, so (A) and (B) cannot appear in the same set of statements (as (A) implies (B)). Hence one of them must appear in each set, which means one of the numbers is 3-digit and the other is less than a thousand. This gives us an upper bound on the numbers we are looking for.

The condition (H) must be part of Susan’s puzzle. So we can solve Keith’s puzzle first using 4 of the conditions (A)-(G), and then check that the remaining 3 conditions with the additional condition (H) give a viable puzzle for Susan.

This Python program runs in 203ms.

Run:[ @repl.it ]Solution:Keith’s puzzle uses clues (B) (D) (F) (G). The answer to Susan’s puzzle is 841.Keith’s puzzle was:

The unique solution to this puzzle is (a bit disappointingly) 1.

None of the clues is redundant:

Susan’s puzzle was:

The unique solution to this puzzle is 841 (= 29²).

None of the clues is redundant:

Originally I thought there was a further solution to the Enigma:

But in this case Susan’s puzzle has the same unique solution if only conditions (A) (D) (H) are considered, so the condition (F) is redundant, and hence this is not a further solution.

In the program we check to see if any of the conditions can be removed while leaving a unique solution (we check numbers up to 2000, because conditions (A) and (B) can be removed), if we do not find any additional solution then the removed condition is redundant.

Thank you for all your efforts on this site. It has provided years of enjoyment.