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 state names that start with the letter N
given 3 sides, find area of this triangle
Project Euler: Problem 10, Sum of Primes
Wrapping the Tower of Pisa
07 - Common functions and indexing 4
Find the outlier in a set of samples
Compress strings (not springs)
Energy of a photon
Given n, create n random numbers such that their standard deviation is also 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