Cody

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

Solution 835023

Submitted on 22 Feb 2016 by Richard Zapor
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.110978 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.049920 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.021563 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)

Elapsed time is 0.027251 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)

Elapsed time is 0.381228 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.169498 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 1.418225 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)

Elapsed time is 1.806601 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 10.287076 seconds.

Suggested Problems

More from this Author246

Community Treasure Hunt

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

Start Hunting!