Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • I have basically no background in algorythm efficiency analysis so I don't focus on it ever so thank you for the explanation and suggestion; I would implement your solution using a .reduce() but it would equate to the same thing.

    I imagine that there are more difficult kata where efficiency of the solution plays a part in success or not and I actually avoid those as it isn't something that I have ever needed to take into account.

  • If you were to use Array.sort(), first create a new array by doing array.slice(0), which will create a shallow copy of the input array. Then it can be sorted without mutating the input.

    However, just using a simple for loop allows you to complete this Kata in O(n) instead of O(n log(n)); Using sort means that for large arrays you're going to see a huge performance disadvantage versus just finding the max and second max using a for loop.

  • Thanks for the comment. What solution suggestion do you have?

  • Any solution using sort isn't best practice, as it's possible to complete this Kata in one iteration over the input array instead of spending time to sort it.

    (not to mention, this mutates the input array as well!)

  • This solution does not work anymore as there is an overflow. BigInteger should probably be used.

  • Maybe the associated tests were updated in the meanwhile.

  • How this code pass the test??? my first attemp with something similar failed 3 of the test... maybe the test where updated since this???

  • That was my fist try it did not pass BigInts and Null value :(

  • Hi, I've added a CoffeeScript translation, if you want to approve it, instructions for the approval process are here.

  • Python tests don't test removing duplicates.

  • The kata is finally approved! Lots of thanks!

  • Mph, I was about to translate it into JS, but I was beatean by less than 24 Hrs :(

    I would suggest that Zozo-senpai now forks is own translation, copy&pastes the current description and then edit it with his integration. Save the forked translation and it should be "approvable" by g964.

    Edit: also, the kata to me is mature enough to be green-lit; the only missing thing would be imho a set of random tests, but we talked about it profusely and I certainly respect your take on the matter. Added a few tags and approved :)

  • You are right, I will do my best!

  • Unfortunately no, it's still the same "...Cannot be approved, recent changes must be merged first"... With the "Fork" button I can run it and it works perfectly well but impossible to approve.
    Same thing as the last time with @bkaes! Maybe he will have an idea.
    He and you are close to the gods of the staff, aren't they able to fix that kind of problem wich must appear often enough:-)
    PS: I will be absent a couple of hours:-(

  • Loading more items...