• Each of ROME, PARIS, ARRAS, ARLON and LENS is a prime number.
• Each of NIMES, ANS, MONS is 7 times the product of a prime number.
• SPA is a perfect square.
What are these numbers ?
primNos={'rome','paris','arras','arlon','lens'};
prime7={'nimes','ans','mons'};
sq='spa';
lets='romeaslnip';
perm=lets(perms(1:10));
for i=1:length(perm)
p=perm(i,:);
sq=str2double(translate('spa',p));
sr=round(sqrt(sq));
if sr^2==sq
good=true;
for j=1:length(primNos)
if ~isprime(str2double(translate(primNos{j},p)))
good=false;
break
end
end
if good
for k=1:length(prime7)
tstprm=str2double(translate(prime7{k},p))/7;
if tstprm==round(tstprm)
if ~isprime(tstprm)
good=false;
break
end
end
end
end
if good
disp(p)
end
end
end
function tr=translate(a,code)
b=zeros(1,length(a));
for i=1:10
c=code(i);
idx=a==c;
b(find(idx))=char(string(i-1));
end
tr=char(b);
end
finds two:
lepnmrosia
onpsaimelr
We'll work with each:
lepnmrosia
0123456789
onpsaimelr
ROME, PARIS, ARRAS, ARLON and LENS
5641 29587 95597 95063 0137 leading zero
9067 24953 49943 49801 8731
so we'll continue with the second possibility:
NIMES, ANS, MONS
15673 413 6013
SPA
324 = 18^2
Edited on January 6, 2024, 9:37 am
Edited on January 6, 2024, 9:38 am
|
Posted by Charlie
on 2024-01-06 09:35:12 |