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 Solvers4165
Suggested Problems
-
872 Solvers
-
Create a cell array out of a struct
970 Solvers
-
All your base are belong to us
486 Solvers
-
4584 Solvers
-
Find out sum of all elements of given Matrix
408 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!