Problem 109. Check if sorted
Solution Stats
Problem Comments
-
10 Comments
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
nice
hehe
The solution "y = issorted(x);" with a metric of 12 is not the leading solution. "Fair Play" is something unknown to cheaters!
Solution Comments
-
1 Comment
Is it supposed to be sorted in ascending or descending order? I'll just pick randomly ...
-
1 Comment
gj
-
1 Comment
This user (mohamed elbesealy) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
-
1 Comment
Similar to monotonically increasing problem.
-
1 Comment
That was hard
-
1 Comment
thank you Emilio
-
1 Comment
haha
-
1 Comment
Additional sort command takes extra node...
-
2 Comments
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.
-
2 Comments
Hard one :)
facepalm
Problem Recent Solvers4240
Suggested Problems
-
Project Euler: Problem 2, Sum of even Fibonacci
1664 Solvers
-
Check if number exists in vector
8472 Solvers
-
670 Solvers
-
428 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
1298 Solvers
More from this Author100
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!