Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 115. Distance walked 1D

Created by AMITAVA BISWAS

Suppose you go from position 7 to 10 to 6 to 4. Then you have walked 9 units of distance, since 7 to 10 is 3 units, 10 to 6 is 4, and 6 to 4 is 2. Total distance traveled = 3 + 4 + 2 = 9.

Example:

 Input  x = [1 2 3 2]
 Output y is 3

Tags

Problem Group

Solution Statistics

1503 correct solutions 875 incorrect solutions
Last solution submitted on May 01, 2016

Problem Comments

Solution Comments