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 :)
Scoring for oriented dominoes
Calculate the area of a triangle between three points
Given area find sides
Sum of odd numbers in a matrix
Remove the Zero
speed vs size
Given an unsigned integer x, find the largest y by rearranging the bits in x
Person of interest?
Energy of a photon
Vectorizing, too easy or too hard?
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