Check if sorted.
Input x = [1 2 0]
Output y is 0
Sort means ascending or descending or both? Not clear
I agree! The code is significantly different for those possible cases.
Unfortunately, way too easy!
I agree it's not clear ... but
y = ~var(nonzeros(sign(diff(x))));
works for both ascending/descending cases.
(The test suite clarifies that ascending is the intended case)
y = ~var(nonzeros(sign(diff(x)))); amazing~ ！nice idea
There is a sort array command in MATLAB.
if you are not familiar with array, will be difficult
The solution "y = issorted(x);" with a metric of 12 is not the leading solution. "Fair Play" is something unknown to cheaters!
Is it supposed to be sorted in ascending or descending order? I'll just pick randomly ...
This user (mohamed elbesealy) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
Similar to monotonically increasing problem.
That was hard
thank you Emilio
Additional sort command takes extra node...
The leading solution (solution 103932) is wrong and doesn't work. The error is that the output argument "ans" is not assigned.
@Norbert, this trick worked in Cody before, now it doesn't. I wrote trick, cause it was a way to have a little bit lower Cody size. It was questioned why it's not banned, because it favours bad programming practices, so changes were made.
Hard one :)
Find the sum of all the numbers of the input vector
Most nonzero elements in row
The Goldbach Conjecture, Part 2
Choose the best fitting dominoes
Produce a sine wave
How to multiply?
chance in percent for minimum K heads when a good coin is tossed N times?
Minimum possible M of the maximum side of a triangle of given area A.
Given a number N, find the smallest prime P>N
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