### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

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

### Site Stats

- 168,355 hits

Programming Enigma Puzzles

16 January 2017

Posted by on **From New Scientist #2288, 28th April 2001** [link]

The PIN code on George’s cash card is a semi-prime number, that is to say it is the product of two different prime numbers. He discovered some time ago that the PIN code multiplied by his car registration number gives his six-digit phone number, which does not begin with a zero. But George has now discovered a slightly more obscure coincidence. If he subtracts his house number from his phone number and multiplies the result by his house number, the result is his phone number with its digits in reverse order!

What is George’s car registration number?

[enigma1132]

Advertisements

%d bloggers like this:

The equation that relates the phone number and the house number is:

Using

pfor the phone number,rfor the reverse of the phone number, andhfor the house number, we derive the following quadratic equation:Which has the following solutions for

husing the standard quadratic formula:This Python program looks for possible solutions for

hfor six-digit numbersp, and then looks at the prime factors ofpto determine possible values for the PIN. It runs in 633ms.Solution:George’s car registration number is 127.The phone number is 499999, which factorises as (31 × 127 × 127).

The PIN is therefore (31 × 127) = 3937, and the car registration number is 127.

The reverse of the phone number is 999994.

If the house number is

hwe have:So the house number is either 2 or 499997. The first of these seems more likely.

The following program uses the

SubstitutedExpression()solver from theenigma.pylibrary to find possible phone numbers using an Alphametic expression.I was pleasantly surprised to find that this program runs in just 187ms.