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.
that's a good code
厉害,一行搞定
I love it. Short. Elegant. Literally does what this function is supposed to do. Change every character except the last 4. Beauty!
This one's hot, love it!
This solution is far more elegant than the top one. In fact, no solution could be simpler than this one.
This comment is hidden because it contains spoiler information about the solution
Indeed thats great solution.
Unfortunately you cannot guarantee reversal with a sorting algorithm. Sorting works by testing two values; if the returned number is > 0, it will swap the values, if <= 0 it will leave them as-is (a generalisation, but you get the idea). The only case where your code would work is if the first and last values are tested (and swapped), then the second and second-to-last values are tested (and swapped), and so on. This tends not to be the case, however. It will test each value a number of times, against different values until it finds the right place for it.
I had originally tried a similar solution to yours, but found it severely lacking, unfortunately. (And I'm the author! ;P)
The reason it seems as though it's the "last" test that fails is, because of how the tests are written, when any test fails the testing will stop. So any failing test will look like the last test. There are 3 basic tests, and then 10 randomly-generated ones; perhaps those are giving you problems?
This comment is hidden because it contains spoiler information about the solution
I believe this to be the superior solution and am amazed that a more abstracted solution is at a higher rating.