Cody

Problem 116. Distance walked 2D

Solution 1120674

Submitted on 11 Feb 2017 by Jihye Sofia Seo
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
xy = [3,4; 0,0; 0,1; 1,1]; z_correct = 7; assert(isequal(walked(xy),z_correct))

xs = 3 0 0 1 ys = 4 0 1 1 xd = -3 0 1 yd = -4 1 0 z = 7

2   Pass
xy = [3,4; 0,0]; z_correct = 5; assert(isequal(walked(xy),z_correct))

xs = 3 0 ys = 4 0 xd = -3 yd = -4 z = 5

3   Pass
xy = [0,0; 5,12; 0,12]; z_correct = 18; assert(isequal(walked(xy),z_correct))

xs = 0 5 0 ys = 0 12 12 xd = 5 -5 yd = 12 0 z = 18

Suggested Problems

More from this Author100

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!