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

Solution 316813

Submitted on 9 Sep 2013 by Suman Saha

Correct

56Size
Leading solution size is 10.
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
 
%%
xy = [3,4; 0,0; 0,1; 1,1];
z_correct = 7;
assert(isequal(walked(xy),z_correct))
xy =
     0     0
     0     1
     1     1
xy =
     0     1
     1     1
xy =
     1     1
ans =
     7
2
Pass
 
%%
xy = [3,4; 0,0];
z_correct = 5;
assert(isequal(walked(xy),z_correct))
xy =
     0     0
ans =
     5
3
Pass
 
%%
xy = [0,0; 5,12; 0,12];
z_correct = 18;
assert(isequal(walked(xy),z_correct))
xy =
     5    12
     0    12
xy =
     0    12
ans =
    18