Cody

Solution 2013595

Submitted on 11 Nov 2019 by cokakola
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
global m mpc mc mpc5c v tic v=1111:6666; vL=length(v); m=zeros(vL,4); for i=1:vL vp=v(i); for k=4:-1:1 m(i,k)=mod(vp,10); vp=floor(vp/10); end end mdel=sum((m==0)+(m>6),2)>0; m(mdel,:)=[]; v=m*[1000;100;10;1]; mL=size(m,1); mpc=zeros(mL); % 0.030 for j=1:mL mpc(:,j)=sum(m==repmat(m(j,:),mL,1),2); end mch=zeros(mL,6); % 0.038 for i=1:mL for k=1:6 mch(i,k)=nnz(m(i,:)==k); end end mc=zeros(mL); % 0.06 for j=1:mL mc(:,j)=sum(min(mch,repmat(mch(j,:),mL,1)),2); end mc=mc-mpc; % remove mpc part mpc5c=5*mpc+mc; fprintf('Initialization %.3f\n',toc) % finished initilaiztion calculation in less than 0.2 sec

Initialization 0.148

2   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 0 0 6 6 6 6 4 0]; % case 947 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

3   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 1 0 3 6 5 6 2 1 6 6 5 5 4 0]; % case 940 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

4   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 2 0 3 6 3 6 0 1 6 4 4 5 3 0 6 5 4 5 4 0]; % case 900 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

5   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 0 1 3 4 3 0 2 4 4 1 5 3 0 1 4 5 6 1 3 6 4 1 5 4 0]; % case 850 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

6   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 0 0 6 6 6 6 4 0]; % case 947 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

7   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 2 2 3 4 3 1 1 2 1 3 5 0 3 6 3 2 1 4 0]; % case 816 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

8   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 2 2 3 4 3 1 1 2 1 3 5 1 2 2 4 5 1 0 2 6 1 2 3 4 0]; % case 750 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

9   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 0 1 3 4 3 0 1 4 2 5 6 0 2 6 5 1 5 1 1 5 5 3 2 4 0]; % case 700 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

10   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 0 0 6 6 6 6 4 0]; % case 947 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

11   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 2 0 3 6 3 6 0 1 6 4 4 5 1 0 5 3 5 5 4 0]; % case 650 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

12   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 0 0 6 6 6 6 4 0]; % case 947 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

13   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 2 0 1 1 3 4 0 2 3 2 1 5 2 2 3 5 1 2 1 3 5 2 1 3 4 0]; % case 600 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

14   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 0 0 6 6 6 6 4 0]; % case 947 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

15   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 1 2 3 4 3 1 2 4 3 2 5 2 1 4 4 2 3 3 0 4 6 2 3 4 0]; % case 550 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

16   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 0 3 3 4 5 1 3 3 4 5 3 2 2 4 3 5 3 4 0]; % case 500 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

17   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 1 2 3 4 3 0 1 4 1 5 6 2 1 4 5 5 1 1 1 4 1 6 4 4 0]; % case 450 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

18   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 0 1 3 4 3 0 3 1 4 4 5 0 2 3 6 1 4 4 0]; % case 400 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

19   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 1 1 3 1 4 1 3 1 1 4 3 0 4 3 4 1 1 4 0]; % case 350 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

20   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 2 1 1 2 3 2 1 1 4 1 5 0 1 3 1 2 2 4 0]; % case 300 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

21   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 0 1 2 3 4 3 2 0 1 3 5 5 1 1 2 6 5 3 1 1 2 5 4 5 4 0]; % case 250 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

22   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 1 1 3 1 4 1 0 1 5 2 6 0 1 2 2 4 4 1 1 2 3 3 2 4 0]; % case 200 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

23   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 2 1 1 2 3 1 2 1 1 1 4 3 0 2 1 1 4 4 0]; % case 150 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

24   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 1 0 1 3 4 3 1 1 3 2 5 3 0 2 1 5 3 6 3 0 1 5 3 5 4 0]; % case 100 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

25   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 2 1 1 1 3 2 2 1 4 1 1 5 0 1 1 3 2 2 4 0]; % case 50 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end

26   Pass
global m mpc mc mpc5c v mm=[1 2 1 2 2 0 1 1 3 4 2 1 1 4 2 5 1 0 1 1 1 3 4 0]; % case 1 [mguessn]=solve_mastermind(mm(1:end-1,1:end-2),mm(1:end-1,end-1:end),m,mpc,mc,mpc5c,v); if isequal(mguessn,mm(end,1:4)) assert(isequal(1,1)) else fprintf('Invalid answer of %i %i %i %i\n',mguessn) assert(isequal(1,0)) end