Cody

# Problem 2085. Sudoku Solver - Standard 9x9

Solution 2161505

Submitted on 16 Mar 2020
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)

Error: File: sudoku_solver.m Line: 4 Column: 12 Invalid syntax for calling function 'mstr' on the path. Use a valid syntax or explicitly initialize 'mstr' to make it a variable. 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)

Error: File: sudoku_solver.m Line: 4 Column: 12 Invalid syntax for calling function 'mstr' on the path. Use a valid syntax or explicitly initialize 'mstr' to make it a variable. 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)

Error: File: sudoku_solver.m Line: 4 Column: 12 Invalid syntax for calling function 'mstr' on the path. Use a valid syntax or explicitly initialize 'mstr' to make it a variable. 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)));

Error: File: sudoku_solver.m Line: 4 Column: 12 Invalid syntax for calling function 'mstr' on the path. Use a valid syntax or explicitly initialize 'mstr' to make it a variable. Error in Test4 (line 12) mout=sudoku_solver(m)