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.
Input x = [1 2 3 2]
Output y is 3
Amitava, can you give a clearer idea of what your function inputs and outputs should look like?
If you leave one test the solution is simply 9. As is this submission is very poor.
Needs generalization and a larger test suite.
This is a pretty good idea for a problem but it's *very* poorly stated.
I cleaned up the problem statement and added a few more tests.
Very good problem. I had to solve the same one to determine whether a signal was oscillating or stable.
i solved it but its size is 62
This user (mohamed elbesealy) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
This gives expected results, but still not accepted. wht is the issue. pls comment
Your function is named abc--the test suite wants it to be named your_fcn_name.
What's the wrong with this solution? It works perfectly on the Matlab R2015b.
sumabs is a function from Neural Network Toolbox which is not supported in Cody.
what is the wrong in my solution?
What is the problem with this solution? It works on matlab
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.)
this is working in matlab environment...i don´t get it...
The test suite wants the function name to be "your_fcn_name".
Return the 3n+1 sequence for n
Extract leading non-zero digit
letter yes yes & letter no no
Test if two numbers have the same digits
Find the hypotenuse
Given a number N, find the smallest prime P>N
Sorted highest to lowest?
pressure to dB?
Minimum possible M of the maximum side of a triangle of given area A.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office