### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,609)
- enigma-book-1982 (70)
- misc (5)
- project euler (2)
- puzzle (90)
- puzzle# (173)
- site news (76)
- tantalizer (189)
- teaser (7)
- today (1)

### Site Stats

- 310,316 hits

Programming Enigma Puzzles

23 May 2022

Posted by on **From New Scientist #2017, 17th February 1996** [link] [link]

The mileage chart shows the distances between various secret government establishments, each of which is designated by a three-digit code. The distance between two locations can be calculated by adding the differences between the three pairs of corresponding digits, ignoring the signs of the differences. Thus the distance between 689 and 773 is (7 − 6) + (8 − 7) + (9 − 3) = 8.

For reasons of security the government wants these locations to be as far apart as possible, and is concerned that two of them are only four miles apart. Locations 000 and 999 must be retained, but the other four can be moved to locations represented by any three-digit codes, to make the closest pair as far apart as possible.

What is the greatest possible distance between the closest pair?

[enigma862]

%d bloggers like this:

This Python program considers

decreasingbounds on the allowable minimum distance, until a viable set of location codes is found.It runs in 83ms. (Internal run time is 19ms).

Run:[ @replit ]Solution:The greatest possible distance between the closest pair is 13 miles.There are many ways of achieving this value.

Here is one: