I am getting a new sign for my shop, and instead of showing the shop number as numeric digits, it
will be spelled out in capital letters, one word per digit. For example, if my shop number were 103, it
would be painted as ONE ZERO THREE.
The sign painter is a little eccentric, and instead of charging by
the hour, he charges by the brush stroke, which can be any shape and can touch, but must not cover, an
already painted area (except where changing direction). He paints capital letters in a simple style (no serifs) and does not use two strokes
where a single stroke will do. For example, E, F, G, H, I, N, O, R, S, T, U, V, W, X, Z would require 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, and 1 strokes, respectively.
My shop number, which I had spelled out for the painter when he arrived, is a prime number, consisting of three different digits. He charges $1 per stroke, regardless of the length of the stroke. By coincidence, the cost of my number in dollars was equal to the sum of the three digits in the shop number and was a prime.
What is my shop number?
clearvars
nos=intersect(primes(1000),100:999);
lets='efghinorstuvwxz';
vals=[2,2,2,3,1,1,1,1,1,2,1,1,1,2,1];
for i=1:length(nos)
tot=0;v=[];
ns=num2str(nos(i));
if isequal(sort(ns),unique(ns))
wds='';
for j=1:3
dig=ns(j);
w=num2words(str2double(dig));
wds=[wds w];
for k=1:length(w)
idx=strfind(lets,w(k));
tot=tot+vals(idx);
v(end+1)=vals(idx);
end
end
if tot==sod(nos(i)) && isprime(tot)
fprintf('%d %d %s ',[nos(i) tot],wds)
fprintf(' %d',v)
fprintf('\n')
end
end
end
finds
829 19 eighttwonine 2 1 2 3 2 2 1 1 1 1 1 2
Showing the shop number is 829, the total value of the digits (and sum of digits) is 19, the letters used are EIGHTTWONINE, with respective values of 2 1 2 3 2 2 1 1 1 1 1 2.
|
Posted by Charlie
on 2024-12-18 14:30:05 |