Cody

Problem 42355. Minimum Set (A+A)U(A*A) OEIS A263996

Solution 1259669

Submitted on 30 Aug 2017 by Alfonso Nieto-Castanon
  • Size: 368
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
tic pass=true; L=8;Best=30;pmax=5;vmax=10; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

Elapsed time is 0.056507 seconds.

2   Pass
tic pass=true; L=39;Best=335;pmax=7;vmax=100; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

Elapsed time is 0.043375 seconds.

3   Pass
tic pass=true; L=50;Best=486;pmax=7;vmax=144; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

Elapsed time is 0.032353 seconds.

4   Pass
tic pass=true; L=40;Best=348;pmax=7;vmax=120; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

349 349 Elapsed time is 0.123768 seconds.

5   Pass
tic pass=true; L=80;Best=1001;pmax=11;vmax=300; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

1003 1013 1008 1005 1005 1005 1011 1007 Elapsed time is 4.290534 seconds.

6   Pass
tic pass=true; L=120;Best=1847;pmax=11;vmax=480; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

Elapsed time is 0.188005 seconds.

7   Pass
tic pass=true; L=160;Best=2864;pmax=11;vmax=840; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

Elapsed time is 0.795538 seconds.

8   Pass
tic pass=true; L=200;Best=4000;pmax=13;vmax=900; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

4015 4005 Elapsed time is 11.254309 seconds.

9   Pass
tic pass=true; L=280;Best=6632;pmax=13;vmax=1800; v = SP(L,Best,pmax,vmax); v=unique(floor(v)); v(v<1)=[]; if length(v)~=L,pass=false;end vm2=zeros(1,v(end)*v(end)); Lv=length(v); vr=repmat(v,Lv,1);vrp=vr'; vp=vr+vrp; %vp=repmat(v,Lv,1)+repmat(v',1,Lv); vm2(vp(:))=1; vm=vr.*vrp; %vm=repmat(v,Lv,1).*repmat(v',1,Lv); vm2(vm(:))=1; scr=nnz(vm2); if scr>Best,pass=false;end toc assert(pass)

Elapsed time is 15.190679 seconds.

Suggested Problems

More from this Author241

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!