Cody

Solution 1788634

Submitted on 15 Apr 2019
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   Fail
% Test 1 mstr=['012300007'; '040600010'; '078900020'; '000000040'; '100000002'; '060000000'; '080001230'; '090004060'; '300007890']; % convert string to array m=zeros(9); for i=1:9 m(i,:)=mstr(i,:)-'0' ; end tic mout=sudoku_solver(m) toc valid=all(arrayfun(@(i) all(sum([mout mout']==i)),1:length(mout))); assert(valid==1) ptr=find(m>0); valid2=isequal(m(ptr),mout(ptr)); assert(valid2==1)

S = 9×9×0 empty double array firstId = 1 i = 1 j = 1 ii = 1 jj = 1 mm = 0 1 2 0 4 0 0 7 8 ii = 1 jj = 1 mm = 0 1 2 0 4 0 0 7 8 ii = 1 jj = 1 mm = 0 1 2 0 4 0 0 7 8 ii = 1 jj = 1 mm = 0 1 2 0 4 0 0 7 8 ii = 1 jj = 1 mm = 0 1 2 0 4 0 0 7 8 M = 5 1 2 3 0 0 0 0 7 0 4 0 6 0 0 0 1 0 0 7 8 9 0 0 0 2 0 0 0 0 0 0 0 0 4 0 1 0 0 0 0 0 0 0 2 0 6 0 0 0 0 0 0 0 0 8 0 0 0 1 2 3 0 0 9 0 0 0 4 0 6 0 3 0 0 0 0 7 8 9 0

Undefined function 'sodoku_solver' for input arguments of type 'double'. Error in sudoku_solver (line 16) S=sodoku_solver(M,S) Error in Test1 (line 10) mout=sudoku_solver(m)

2   Fail
% Test 2 mstr=['000004500'; '000003600'; '432008700'; '867000000'; '000000000'; '000000417'; '001900854'; '006400000'; '003700000']; % convert string to array m=zeros(9); for i=1:9 m(i,:)=mstr(i,:)-'0' ; end tic mout=sudoku_solver(m) toc valid=all(arrayfun(@(i) all(sum([mout mout']==i)),1:length(mout))); assert(valid==1) ptr=find(m>0); valid2=isequal(m(ptr),mout(ptr)); assert(valid2==1)

S = 9×9×0 empty double array firstId = 1 i = 1 j = 1 ii = 1 jj = 1 mm = 0 0 0 0 0 0 4 3 2 M = 1 0 0 0 0 4 5 0 0 0 0 0 0 0 3 6 0 0 4 3 2 0 0 8 7 0 0 8 6 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 1 7 0 0 1 9 0 0 8 5 4 0 0 6 4 0 0 0 0 0 0 0 3 7 0 0 0 0 0

Undefined function 'sodoku_solver' for input arguments of type 'double'. Error in sudoku_solver (line 16) S=sodoku_solver(M,S) Error in Test2 (line 10) mout=sudoku_solver(m)

3   Fail
% Test 3 mstr=['120034000'; '000000056'; '000200000'; '007800002'; '600000001'; '500006300'; '000008000'; '340000000'; '000560078']; % convert string to array m=zeros(9); for i=1:9 m(i,:)=mstr(i,:)-'0' ; end tic mout=sudoku_solver(m) toc valid=all(arrayfun(@(i) all(sum([mout mout']==i)),1:length(mout))); assert(valid==1) ptr=find(m>0); valid2=isequal(m(ptr),mout(ptr)); assert(valid2==1)

S = 9×9×0 empty double array firstId = 2 i = 2 j = 1 ii = 1 jj = 1 mm = 1 2 0 0 0 0 0 0 0 ii = 1 jj = 1 mm = 1 2 0 0 0 0 0 0 0 ii = 1 jj = 1 mm = 1 2 0 0 0 0 0 0 0 ii = 1 jj = 1 mm = 1 2 0 0 0 0 0 0 0 M = 1 2 0 0 3 4 0 0 0 4 0 0 0 0 0 0 5 6 0 0 0 2 0 0 0 0 0 0 0 7 8 0 0 0 0 2 6 0 0 0 0 0 0 0 1 5 0 0 0 0 6 3 0 0 0 0 0 0 0 8 0 0 0 3 4 0 0 0 0 0 0 0 0 0 0 5 6 0 0 7 8

Undefined function 'sodoku_solver' for input arguments of type 'double'. Error in sudoku_solver (line 16) S=sodoku_solver(M,S) Error in Test3 (line 10) mout=sudoku_solver(m)

4   Fail
% Timed Test on a Hard Sudoku % Non-Valid answer creates a Max score but not a fail % Hard Sudoku mstr=['005700009'; '030090010'; '100005300'; '600004700'; '040010050'; '002500001'; '004600002'; '080020040'; '200008600']; % convert string to array m=zeros(9); for i=1:9 m(i,:)=mstr(i,:)-'0' ; end time0=cputime; mout=sudoku_solver(m) etime=(cputime-time0)*1000 % msec valid=all(arrayfun(@(i) all(sum([mout mout']==i)),1:length(mout))); ptr=find(m>0); valid2=isequal(m(ptr),mout(ptr)); % Not Asserting for Valid answer if ~valid,etime=500;end if ~valid2,etime=500;end assignin('caller','score',min(500,floor(etime)));

S = 9×9×0 empty double array firstId = 1 i = 1 j = 1 ii = 1 jj = 1 mm = 0 0 5 0 3 0 1 0 0 ii = 1 jj = 1 mm = 0 0 5 0 3 0 1 0 0 ii = 1 jj = 1 mm = 0 0 5 0 3 0 1 0 0 ii = 1 jj = 1 mm = 0 0 5 0 3 0 1 0 0 M = 4 0 5 7 0 0 0 0 9 0 3 0 0 9 0 0 1 0 1 0 0 0 0 5 3 0 0 6 0 0 0 0 4 7 0 0 0 4 0 0 1 0 0 5 0 0 0 2 5 0 0 0 0 1 0 0 4 6 0 0 0 0 2 0 8 0 0 2 0 0 4 0 2 0 0 0 0 8 6 0 0

Undefined function 'sodoku_solver' for input arguments of type 'double'. Error in sudoku_solver (line 16) S=sodoku_solver(M,S) Error in Test4 (line 12) mout=sudoku_solver(m)

Suggested Problems

More from this Author276