Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

236Size
Leading solution size is 174.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
tic
zm=[0 1 ;1 0 ];
zsf=[1 1 2 2 ];
vexp='';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
2
Pass
 
%%
zm=[0 1 1 0 1 ;0 0 0 0 0 ;0 0 0 1 0 ;0 1 1 1 0 ;0 0 0 1 0 ];
zsf=[1 1 5 3 ];
vexp='SEEENSESSSNNNWWSWWSSEE';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
3
Pass
 
%%
zm=[0 0 0 ;0 1 0 ;0 0 0 ];
zsf=[1 1 3 3 ];
vexp='EESS';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
4
Pass
 
%%
zm=[0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ];
zsf=[1 1 2 2 ];
vexp='';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
5
Pass
 
%%
zm=[0 1 0 1 0 1 0 1 ;0 0 0 0 0 0 0 0 ;1 1 1 1 1 1 1 0 ;0 0 0 0 0 0 0 0 ;0 1 0 1 0 1 0 1 ;0 1 1 1 1 1 1 1 ;0 1 0 1 0 1 0 1 ;0 0 0 0 0 0 0 0 ];
zsf=[1 1 8 8 ];
vexp='SEENSEENSEENSESSWSNWWSNWWSNWWSSSSEENSEENSEENSE';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
6
Pass
 
%%
zm=[0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ];
zsf=[1 10 1 4 ];
vexp='SSSSSSSSSWWWWWWWWWNNNNNNNNNEEE';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
7
Pass
 
%%
zm=[0 0 0 0 0 0 0 0 0 1 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ];
zsf=[1 1 3 1 ];
vexp='EEEEEEEESESSSSSSSSWWWWWWWWWNNNNNNN';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
8
Pass
 
%%
zm=[0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 1 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ];
zsf=[1 1 7 1 ];
vexp='EEEEEEEEESSSSSSSSSWWWWWWWWWNNN';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
9
P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 0 0 0 0 ];
zsf=[10 10 8 10 ];
vexp='WWWWNWWSWWWNNNNNNNNNEEEEEEEWSWSWSSEENEENNESSSSWWSSEE';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
22
Pass
 
%%
zm=[0 0 0 0 1 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;1 1 0 0 0 0 0 0 0 0 ;1 0 0 0 0 1 0 0 0 0 ;0 0 0 0 0 0 0 1 1 0 ;0 0 0 0 0 0 1 0 0 1 ;0 0 0 0 0 0 0 0 0 0 ;0 1 0 0 0 1 0 0 0 0 ;1 0 1 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ];
zsf=[10 1 10 10 ];
vexp='ENSEENNWNWWSNNNENENNWWNEEESEENEEEESSSSNWWWSWSSEENESESSS';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
23
Pass
 
%%
zm=[0 0 0 0 1 0 0 0 0 0 ;1 1 1 0 0 0 1 0 0 0 ;0 0 1 1 1 0 1 0 0 0 ;0 0 0 1 1 0 0 0 0 0 ;0 0 1 0 0 0 0 0 0 1 ;0 0 0 0 0 0 0 0 0 0 ;0 1 0 0 0 0 0 0 1 0 ;0 0 0 1 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 1 0 0 0 0 0 0 0 ];
zsf=[10 10 6 10 ];
vexp='WWWWWWNWWSWNNNNNNNESEWSSEENEENNNWWNWWWEEESEENEEEESSSWSSE';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
24
Pass
 
%%
zm=[0 0 0 1 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 1 0 ;0 0 0 0 0 0 1 0 0 0 ;0 0 0 0 0 1 1 0 0 1 ;0 0 0 0 0 0 0 1 0 0 ;1 0 0 0 0 1 0 0 1 0 ;0 0 0 0 0 0 0 0 0 1 ;0 0 0 1 1 0 1 0 0 0 ;0 1 1 1 0 0 0 1 0 0 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 ;0 0 0 0 0 0 0 0 1 0 ;0 0 0 0 1 0 0 0 1 0 ];
zsf=[1 1 7 4 ];
vexp='EEEEESSEENNEESSSSSSSSSNNWWSSWWNWWSWWWNNEENNWNWESESE';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
28
Pass
 
%%
zm=[0 1 0 0 1 1 1 0 1 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 1 0 0 0 0 1 0 0 ;0 0 0 1 1 1 0 0 0 0 ;1 1 1 0 0 0 0 0 1 0 ;0 1 0 0 0 1 0 0 0 1 ;0 0 1 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 1 0 0 0 0 ;0 0 0 1 0 0 0 0 0 0 ];
zsf=[10 1 10 5 ];
vexp='NNNNSESEENNWENEEENNWWWNWWSSEWWNNNSEENESEEEENSEENSSSSNWWSSESESSSWWWWW';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
29
Pass
 
%%
zm=[0 0 0 0 0 0 1 1 0 1 ;0 0 1 0 0 0 0 0 0 0 ;0 1 0 1 0 0 0 0 1 0 ;0 0 0 0 1 0 0 0 0 0 ;0 1 0 0 0 0 0 0 0 1 ;0 0 0 0 1 0 0 1 0 0 ;0 0 0 0 1 0 0 1 0 1 ;0 0 0 0 0 1 0 0 1 0 ;0 0 0 0 0 1 1 0 0 0 ;0 0 1 0 0 0 1 0 0 0 ];
zsf=[10 1 9 2 ];
vexp='NNNNNNNNNEEEEESEEENSESSWSSEWSNNWWSSSESEENSSWWNNWNWNNWWSSSESSEWWNWW';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))

                    
30
Pass
 
%%
zm=[0 0 0 1 0 0 1 0 0 0 ;1 0 0 0 0 1 1 0 0 1 ;0 0 1 1 0 0 0 0 1 0 ;0 1 0 1 0 0 0 0 1 0 ;1 1 0 0 0 0 0 0 0 0 ;1 1 0 0 0 0 0 0 0 0 ;0 0 0 0 0 0 0 0 0 0 ;0 0 1 0 0 0 0 0 0 0 ;1 0 0 0 1 0 0 0 0 1 ;0 0 0 0 0 1 0 1 0 0 ];
zsf=[10 1 8 4 ];
vexp='ENNWNEENNNSEENNNWWWSWSNENNWEESEENEWSSEEENNEEWSWSSSEENNSSSSSWSSEWNWWSNWNWW';
vstr=Maze_CH(zm,zsf);
assert(strcmp(vstr,vexp))
toc
Elapsed time is 0.182583 seconds.