Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Works fine for me now. Thank you very much for the quick respond and fix.
there was a bug in the random tests, due to careless division that could yield a NaN when the length of the array is
0
. can you check if it is good for you know ?I am trying to solve this cata in C. What does -nan mean. My solution does not work for navg = -nan.
Thanks, looking back it's most probably too clever. Negative detection could simply be xneg = (x < 0); more readable and code generation would be same or better because it wouldn't confuse optimizers about the intent.
I love this solution. It is like a puzzle that needs to be solved. Clever.XD
Thanks again for the insightful explanation. It is also very interesting to see how qsort is implemented in glibc.
Despite its name, the C standard does not mandate that implementations of
qsort()
use the quicksort algorithm. In fact, it does not even require aO(n log n)
complexity forqsort()
, though of course most clibs will make it as fast as possible because it is an important function. So you cannoy rely on its stability.That being said, it seems like the glibc standard library (the one used on Codewars, which runs on Linux) uses mergesort in most cases; and "most merge sort implementations produce a stable sort". Do not rely on it though, it is an implementation detail. If you need a stable sort, make it stable yourself, e.g. by comparing the pointers themselves in case of structural equality.
This comment is hidden because it contains spoiler information about the solution
Nice. That's why you should consider to learn some math to become a better programmer. ;)
Thank you very much for the detailed answer.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
i don't get it. XD
Loading more items...