clearvars,clc
X=1:8;
best=inf;
for card=1:4
setA=combinator(8,card,'c');
for i=1:length(setA)
A=setA(i,:);
B=setdiff(X,A);
s=prod(A)+prod(B);
if s<best
best=s;
bestA=A;
bestB=B;
end
end
end
best
bestA
bestB
finds
best =
402
bestA =
4 6 8
bestB =
1 2 3 5 7
|
Posted by Charlie
on 2023-06-20 14:04:12 |