Ad
  • Custom User Avatar

    Not an issue

  • Custom User Avatar

    If you are looking for fastest solution, for loop should always be faster than any Array prototype methods.

    A faster Array prototype method for this problem should be a single reduceRight since there is no concat required after as opposed to a filter solution.

  • Custom User Avatar

    Great thanks for the test, my solution was the slowest unexpectedly.

  • Custom User Avatar

    These people are right. You're a horrible person for making this a competition. Here's my entry that ran over 330 million times compared the the 2nd best of 42K.

    AMAZING FOR LOOP-POWERED SPEED!!!111!!

    Lol.

    In all seriousness though, it's only a constant factor improvement. The time complexity of the top ranked solution is the same as that of the rest of ours and it's extremely clear code. I would use filter myself in 99% of work situations and only bust out the for loops and array arithmetic if something needed the optimization. 99% of the time clarity is worth more. I voted up the double filter solution.

  • Custom User Avatar

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

  • Default User Avatar

    Here's my triangle. My method is 100% cheap and obnoxious. Hopefully it's good for a laugh though.

    http://www.codewars.com/kata/reviews/52945ce49bb38560fe0001dc/groups/537fb57dc7017521fe001301

  • Default User Avatar

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

  • Default User Avatar

    What makes a "good" solution also depends on the target platform. Is a "good" solution one that is optimized for the JavaScript V8 engine v3.15, or is a good solution one that is also able to run on older JavaScript versions or one that makes use of the most modern features like those provided in ECMAScript 6? In the real word in client-side programming you usually have to support various JavaScript interpreters of different age each with their own quirks (just think of Internet Explorer). A good solution is one that works on all of these platforms, but it is usually not the most elegant solution.

  • Custom User Avatar

    Interesting phrasing... yes, let's leave 'best' solution to the boffins and just be satisfied with defining a 'good' solution.

    To my mind a 'good' solution has three goals:

    1. it works, in this case it satisifies the test cases for the kata.
    2. it has no side-effects; it doesn't break something else.
    3. it optimises for something, and that optimisation goal is valid in the context the code was written.

    So in the context of these kata, then creating global vars would violate term 2 above and be judged as 'bad'.

    What to optimise for is left to the coder...maybe we should have to state what we're optimising for in each kata?

  • Default User Avatar

    The [8, Draw!] means that the computers places his mark on 8 and with that, the game ends in a draw. The [0, Draw!] means that all marks are set already, so the computer has no move any more, i.e. the game ended in a draw with the last move of the human.

  • Custom User Avatar

    :) top reply, well done, I withdraw any accusation of making a dick move :)

    We kinda need criteria to judge "best"... it's not always performance. In fact, for a vast majority of commercial coding I think readability trumps performance (which clearly this solution fails at too!).

    Also, there really is no one "best" solution for a problem, well, real-world problems at least. But at least we can think about finding the best one :)

  • Custom User Avatar

    um, it's not a competition... we're learning here. Trying to make coding a competitive activity is a dick move.

  • Custom User Avatar

    Though mutating a parameter passed as reference is sort of unexpected.

  • Custom User Avatar

    Now I saw it! And yeah, shifting left is definitely a wiser and more performing option for this one! []s

  • Default User Avatar

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