**From New Scientist #2896, 22nd December 2012** [link]

I have given each letter of the alphabet a different whole-number value from 1 to 26. Therefore I can now work out the value of any word by adding up the values of its letters. For example, XMAS and GIFTS both make 34. It turns out that all the following words have the same value as each other: WE THREE KINGS OF ORIENT ARE.

What are the values of A, N, S, W, E and R?

This puzzle was published a day earlier than I was expecting. And I’d sort of been expecting something to do with taxi cabs for **Enigma 1729**.

[enigma1729]

### Like this:

Like Loading...

*Related*

The following Python program is not particularly pretty, but it gets the answer (and the two possible methods of arriving at it) in 3.1s.

Solution:A=17 N=4 S=3 W=26 E=5 R=9.Here’s a slightly different approach, that works by constructing the possible sets of numbers of a certain length that sum to a certain number. It’s a bit more satisfying, and runs in 995ms, and I may be able to get it faster by tweaking the order the sums are considered in.

As Peter Hayes points out on the New Enigma site, you can simplify the requirements to two equations that contain enough information to solve the puzzle. This adaptation of the above Python program runs in 696ms.

MiniZinc produced a simple, fast solution.

It found 18 whole alphabet solutions in 149 msec.

All the solutions for A,N,S,W,E,R were as found previously, with the variations in values occurring in the letters B,C,D and J

@Naim: Did you get this to run in a reasonable time? I think considering the possible permutations of the 15 letters we’re interested in would be a lot faster that just randomly shuffling the entire alphabet. But even that doesn’t seem like would be an approach that would find the answer in a reasonable time.

Yes, a bit messy this week.

Not a particularly fast program:

Amazing what you can do with a bit of profiling:

Hi Arthur, How do you justify the maximum for r and e on line 7, i.e. 27 – (o+i+n+t)?

I got a few letters mixed up. The code should have been

we=orient ⇒w=orint<=26

⇒ rint≤26 ⇒ no letter

in rint >18

w=orint<=26 ⇒o≤26-rint

f=rint+e≤26 ⇒ e≤26-rint

h=orient-tree=orint-tre, orint≤26 ⇒orint-tre=h≤26

a=orient-re=oint. orint<=26 ⇒a=oint≤26

What do you mean no taxis?

We three kings of orient are

One in a taxi, one in a car

One on a scooter beeping his hooter

…

🙂

I think we used to sing: “one on a bike, and one in a car…”

Imagine a King getting into a taxi and saying “follow that star”

The algorithm is based upon “orient” word, and the word’s permutations are checked, and then some candidates are eliminated in order to satisfy the condition given in the problem.

ORIENT’s letters sum is 31 and ANSWER’s letters sum is a square number.