You are viewing a single comment's thread from:

RE: Intelligence Contest #7 - Win 100% of the SBD + Free Votes

in #contest7 years ago

If anyone is interested. here's the matlab code:

string1=0;
string2=0;
string3=0;
string4=0;
cnt=1;
vals=[0 0 0];
for ida=1:4
if(ida==1)
string1=' +';
elseif(ida==2)
string1=' -';
elseif(ida==3)
string1='.';
else
string1='./';
end
for idb=1:4
if(idb==1)
string2=' +';
elseif(idb==2)
string2=' -';
elseif(idb==3)
string2='.
';
else
string2='./';
end
for idc=1:4
if(idc==1)
string3=' +';
elseif(idc==2)
string3=' -';
elseif(idc==3)
string3='.';
else
string3='./';
end
for idd=1:4
if(idd==1)
string4=' +';
elseif(idd==2)
string4=' -';
elseif(idd==3)
string4='.
';
else
string4='./';
end
eval(strcat('vals(cnt,:)=[13 2 7]',string1,'[4 9 5]',string2,'[6 4 24]',string3,'[3 2 3]',string4,'[3 9 6]'))
stringmult(cnt,1:8)=strcat(string1,string2,string3,string4);
cnt=cnt+1;
end
end
end
end
error=abs((vals-[47 7 21]));
error=sqrt(error(:,1).^2+error(:,2).^2+error(:,3).^2);

[minerr,pos]=min(error)
stringmult(pos,:)
eval(strcat('result=[13 2 7 16]',stringmult(pos,1:2),'[4 9 5 12]',stringmult(pos,3:4),'[6 4 24 6]',stringmult(pos,5:6),'[3 2 3 1]',stringmult(pos,7:8),'[3 9 6 5]'))
%check whether there is another solution
[minerr2,pos2]=min([error(1:pos-1); error(pos+1:end)])

Sort:  

Uhh, that's horrible to read. Is it possible to publish programming code in a readable form on steem?

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 63557.03
ETH 3400.90
USDT 1.00
SBD 2.44