### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,820 hits

Advertisements

Programming Enigma Puzzles

2 November 2015

Posted by on **From New Scientist #2351, 13th July 2002** [link]

You are probably familiar with the word-chain game where you have to get from one word

to another by changing one letter at a time, making a proper word at each stage.

For example one shortest chain for changing DAMN to LOVE is:DAMN – DAME – DOME – DOVE – LOVE.

Your task today is to find a shortest chain from MALE to DIRT. But your chain has to have a further property. You have to consistently replace each letter by a non-zero digit throughout the chain, different digits being used for different letters. For example, one such substitution in the above chain yields:

1863 – 1869 – 1769 – 1749 – 5749.

In that chain some of the four-figure numbers are prime and some are not. But in your substitution for a shortest MALE to DIRT chain all the four-figure numbers must be primes less than 2500.

What is the number for MALE?

[enigma1195]

Advertisements

%d bloggers like this:

The shortest possible chains will have 3 intermediate words, with one of the four letters/digits being changed at each step.

This Python 3 program looks for chains of 5 primes where each of the four digits are changed in one of the transitions. Then by considering the first prime to correspond to MALE and the final prime to correspond to DIRT we can assign letters to each of the primes. We then eliminate chains where the “words” created by substituting letters for digits do not appear in a suitable word list.

I’ve used the

sowpods.txtlist of validScrabblewords (that I used inEnigma 288a) but other word lists can be used.This Python 3 program runs in 245ms (using

sowpods.txt).Solution:MALE = 2459.The three chains I found are:

MALE → DALE → DARE → DIRE → DIRT / 2459 → 1459 → 1489 → 1789 → 1783

MALE → DALE → DARE → DART → DIRT / 2459 → 1459 → 1489 → 1483 → 1783

MALE → DALE → DALT → DART → DIRT / 2459 → 1459 → 1453 → 1483 → 1783

DALT is apparently an obsolete Scottish word for a foster child.

When considering the chains of numbers the program finds additional chains from 1783 → 2459, but these require use of the words MIRT and MILT. There are also additional solutions from 2459 → 1783 that use the word DILT. But the only valid numerical chains are between 2459 and 1783.

If the maximum prime is raised to 2543 then we can find additional chains from 2543 → 1789 (e.g. MALE → DALE → DARE → DIRE → DIRT / 2543 → 1543 → 1583 → 1783 → 1789).