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 :)
Make a checkerboard matrix
Swap the first and last columns
Sum all integers from 1 to 2^n
Back to basics 10 - Max Float
07 - Common functions and indexing 5
Multiply to the limit?
Given a number N, find the smallest prime P>N
swap sign sum & multiply castles
peta to nano (x-ray)
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