## Teaser 1908: Dunroamin

**From The Sunday Times, 11th April 1999** [link]

At our DIY store you can buy plastic letters of the alphabet in order to spell out your house name. Although all the A’s cost the same as each other, and all the B’s cost the same as each other, etc., different letters sometimes cost different amounts with a surprisingly wide range of prices.

I wanted to spell out my house number:

FOURand the letters cost me a total of £4. Surprised by this coincidence I worked out the cost of spelling out each of the numbers from

ONEtoTWELVE. In ten out of the twelve cases the cost in pounds equalled the number being spelt out.For which house numbers was the cost different from the number?

This puzzle was included in the book *Brainteasers* (2002, edited by Victor Bryant). The puzzle text above is taken from the book.

[teaser1908]

## Jim Randell 10:37 am

on8 October 2020 Permalink |(See also:

Teaser 2756,Enigma 1602).This Python program checks to see if each symbol can be assigned a value that is a multiple of 25p to make the required 10 words correct (and also checks that the remaining two words are wrong).

Instead of treating the letters

G,H,R,Useparately, we treat them asGH,HR,UR, which reduces the number of symbols to consider by 1.The program runs in 413ms.

Run:[ @repl.it ]Solution:NINEandTENdo not cost an amount equal to their number.One way to allocate the letters, so that

ONE…EIGHT,ELEVEN,TWELVEwork is:(In this scheme:

NINEcosts £3 andTENcosts £1).But there are many other possible assignments.

You can specify smaller divisions of £1 for the values of the individual symbols, but the program takes longer to run.

It makes sense that

NINEandTENdon’t cost their value, as they are short words composed entirely of letters that are available in words that cost a lot less.Here’s a manual solution:

We note that

ONE+TWELVEuse the same letters asTWO+ELEVEN, so if any three of them are correct so is the fourth. So there must be 0 or 2 of the incorrect numbers among these four.Now, if

ONEandTENare both correct, then any number with value 9 or less with aTin it must be wrong. i.e.TWO,THREE,EIGHT. Otherwise we could makeTENfor £10 or less, and have some letters left over. And this is not possible.If

ONEis incorrect, then the other incorrect number must be one ofTWO,ELEVEN,TWELVE, and all the remaining numbers must be correct. So we could buyTHREEandSEVENfor £10, and have the letters to makeTEN, withEEEHRSVleft over. This is not possible.So

ONEmust be correct, andTENmust be one of the incorrect numbers.Now, if

NINEis correct, then any number with value 7 or less with anIin it must be incorrect. Which would meanFIVEandSIXare incorrect. This is not possible.Hence, the incorrect numbers must be

NINEandTEN.All that remains is to demonstrate one possible assignment of letters to values where

NINEandTENare incorrect and the rest are correct. And the one found by the program above will do.LikeLike

## GeoffR 6:36 pm

on8 October 2020 Permalink |I used a wide range of upper .. lower bound values for letter variables.

The programme would not run satisfactorily under the Geocode Solver, but produced a reasonable run time under the Chuffed Solver. It confirmed the incorrect numbers were NINE and TEN.

LikeLike

## Frits 7:47 pm

on11 October 2020 Permalink |@GeoffR, As Jim pointed out to me (thanks) that FOUR can not be an incorrect number your MiniZinc program can be adapted accordingly. Now both run modes have similar performance.

LikeLike

## Frits 4:56 pm

on11 October 2020 Permalink |Pretty slow (especially for high maximum prizes).

I combined multiple “for loops” into one loop with the itertools product function so it runs both under Python and PyPy.

@ Jim, your code has some unexplained “# can’t include FOUR” code (line 62, 63).

It is not needed for performance.

LikeLike

## Jim Randell 5:17 pm

on11 October 2020 Permalink |@Frits: The fact the

FOURcannot be one of the incorrect numbers is one of the conditions mentioned in the puzzle text.LikeLike

## GeoffR 8:56 am

on12 October 2020 Permalink |@Frits: I never used the fact that FOUR cannot be one of the incorrect numbers.

I only spelt out a condition in the teaser as part of the programme ie F+O+U+R = 400.

I do not think my programme needs adapting – is OK as the original posting.

LikeLike