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.
The java class is now implemented.
Your
results
array will have the wrong length and your are mixing up the order of the indices ofvotes
. Most likely that would cause an ArrayIndexOutOfBoundsException eventually. I haven't run the code, so maybe there is some other mistake as well.Yeah, well I guess the idea is to just fix timmys broken sort, also I'm pretty sure that's quiet unavoidable.
Your stream should definitely be stateless. This does not mean that values inside the stream shouldn't change (they should, that's what map is for), but they must not change (or, ideally, even rely upon) values outside the stream*. Additionally, once a stream has been used (IntStream output, in your case), it can't be used again. If you look at the method signature for IntStream::mapToObject, you'll notice it returns a new Stream. If you want to perform additional functions upon your stream, this new stream is the one you need to act upon.
* Depending on what you're doing, you may want something like an AtomicInteger for counting, but you must remember it can be acted upon by multiple instances of the stream in a parallel environment (if you aren't synchronized). When it comes to lambdas, if something can be done stateless, it should be done stateless.
This comment is hidden because it contains spoiler information about the solution
Which language?
PS: I can't anymore modify the kata because more than 500 codewarriors (735) succeeded:-(