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

Learn moreOpportunities for recent engineering grads.

Apply TodaySuppose 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

1577 correct solutions
950 incorrect solutions

Last solution submitted on Jul 31, 2016

10 players like this problem

2 Comments

Uttam Landage
on 25 Mar 2016

This gives expected results, but still not accepted. wht is the issue. pls comment

Tim
on 25 Mar 2016

Your function is named abc--the test suite wants it to be named your_fcn_name.

2 Comments

Md Tariqul Islam
on 25 Nov 2015

What's the wrong with this solution? It works perfectly on the Matlab R2015b.

Jan Orwat
on 25 Nov 2015

sumabs is a function from Neural Network Toolbox which is not supported in Cody.

1 Comment

SRUJANAV
on 25 May 2015

what is the wrong in my solution?

2 Comments

SAMET YILDIZ
on 15 Jul 2014

What is the problem with this solution? It works on matlab

Andrew Small
on 17 Mar 2015

The test suite expects the function's name to be 'your_fcn_name', instead of distanceWalked. (Which would have been a much more sensible name.)

1 Comment

Marios
on 19 Feb 2014

sumabs()

10 Comments