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.
7kyu problem, unless you know math formulae. Not a fan.
Please use spoiler flag next time, your post was visible in the homepage.
This comment is hidden because it contains spoiler information about the solution
What do you need clarification about? First you sort the array in descending order, then you sum up the differences.
instructions it not clear about sorting stuff need more clarify explanation and some additional example
Can someone explain what kind of calculation this kata wants from me? Right now I 'am sorting the array in descending order, splitting the are in half so I get two arrays and then subtract from the first index until there is no more elements in the array in both arrays and then I add the arrays(Sum) together.
It seems I 'am missunderstanding the description.
Description will lead you into O(nlog(n)) solution at most.
It would be helpful to have in the description info that there is a neat O(n) math solution to the problem.
that's not a proper issue report
per the description your code must handle empty vectors and return
0
in that case; but your code crashes because in the loopyou dereference an empty vector, which is undefined behavior.
Please ask
questions
to ask for help in the future, anissue
is a provable flaw in the kata ;-)CoffeeScript translation
pure fun
good kata, but instruction should be clearer regarding sorting
This comment is hidden because it contains spoiler information about the solution
Sample tests for C and NASM have a minor bug, if you get the answer wrong for the array of length 0, you crash with a SIGSEGV. (At first I thought I may have messed up seriously somewhere lol).
This seems to be because you slip into an unwanted loop here:
RISCV Translation
Loading more items...