Ad
  • Custom User Avatar

    The java class is now implemented.

  • Custom User Avatar

    Your results array will have the wrong length and your are mixing up the order of the indices of votes. Most likely that would cause an ArrayIndexOutOfBoundsException eventually. I haven't run the code, so maybe there is some other mistake as well.

  • Custom User Avatar

    Yeah, well I guess the idea is to just fix timmys broken sort, also I'm pretty sure that's quiet unavoidable.

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Which language?
    PS: I can't anymore modify the kata because more than 500 codewarriors (735) succeeded:-(