### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

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

### Site Stats

- 166,224 hits

Programming Enigma Puzzles

9 September 2016

Posted by on **From New Scientist #1510, 29th May 1986** [link]

“How can one inch, one foot, one yard, one furlong and one mile be only 249 inches?” asked Albert, who was looking at a calculation in the Tarizania University library.

“Simple,” replied the librarian. “That sum was done before we adopted the English system of metrication.”

“How many furlongs to the mile were there?”

“Perhaps you would like to work out that prime number if I tell you that there were more furlongs to the mile than yards to the furlong, more yards to the furlong than feet to the yard and more feet to the yard than inches to the foot,” said the librarian.

What is the answer to Albert’s question?

[enigma361]

Advertisements

%d bloggers like this:

I assumed that the multipliers in each case were integers.

This Python program runs in 38ms.

Solution:There are 7 furlongs to the mile.There are 2 inches in a foot. 1 foot = 2 inches.

There are 3 feet in a yard. 1 yard = 6 inches.

There are 5 yards in a furlong. 1 furlong = 30 inches.

There are 7 furlongs in a mile. 1 mile = 210 inches.

1 mile + 1 furlong + 1 yard + 1 foot + 1 inch = (210 + 30 + 6 + 2 + 1) inches = 249 inches.

Without the restriction that

Mis prime there is an additional solution off=2,y=3,F=4,M=9.I’ve also made a Python library that runs a

MiniZincmodel and parses the output, which means you can do any additional post-processing and output using Python.This Python program uses a MiniZinc model to generate candidate solutions, then the Python code checks that

Mis prime, and produces the output.Overall run-time for this program is 116ms.

The code for

minizinc.pyis available on GitHub.