I have searched in an extensive English dictionary to find a matching word, describing a possible cooperation between two prominent politicians:
BIDEN+TRUMP= ???
I have found two reasonable answers.
Can you find them (or more)?
clearvars
orders=perms('0':'9');
pats=string.empty(0);
for i=1:length(orders)
biden=str2double(orders(i,1:5));
trump=str2double(orders(i,6:10));
total=biden+trump;
p=lexPattern([orders(i,1:5) orders(i,6:10) num2str(total)]);
pats(end+1)=string(p);
end
[pats idx]=sort(pats);
orders=orders(idx,:);
ct=1;
goodpats=string.empty(0);
goodords=char.empty(0,10);
for i=2:length(orders)
if pats(i)==pats(i-1)
ct=ct+1;
else
if ct==1
goodpats(end+1)=pats(i-1);
goodords(end+1,:)=orders(i-1,:);
end
ct=1;
end
end
if ct==1
goodpats(end+1)=pats(end);
goodords(end+1,:)=orders(end,:);
end
goodtots=string.empty(0);
for i=1:length(goodpats)
goodp=char(goodpats(i));
goodtots(end+1)=string(goodp(11:end));
end
fid=fopen('c:wordswords.txt','r');
sol=string.empty(0);
while ~feof(fid)
w=fgetl(fid);
if ismember(length(w) , [5 6])
if ismember(string(lexPattern(['bidentrump' w])),goodpats)
sol(end+1)=string(w);
disp([w ' ' goodords(goodpats==lexPattern(['bidentrump' w]),:)])
else
xx=99;
end
end
end
fclose('all')
where lexPattern is
function cd=lexPattern(n)
rp='a';
ns=char(string(n));
repl=repmat(' ',1,length(ns));
for i=1:length(ns)
if repl(i)==' '
ix=strfind(ns,ns(i));
repl(ix)=rp;
rp=char(rp+1);
end
end
cd=repl;
end
finds five candidates for the total that will give a unique solution:
total BIDEN TRUMP
buppie 12537 94086
redipt 60245 81793
rident 92408 31675
untrim 56093 82174
untrue 94035 62178
where each line shows the word representing the total, followed by the numerical values of BIDENTRUMP. So for example,
BIDEN 94035
+ TRUMP + 62178
------- -------
UNTRUE 156213
Edited on May 2, 2024, 9:56 am
|
Posted by Charlie
on 2024-05-02 09:35:21 |