Ad
  • Custom User Avatar

    if you omit curly brackets when using arrow function you don't have to use "return" keyword

  • Custom User Avatar

    horrible description for 7 kyu

    Any suggestions for improvement?

  • Default User Avatar

    horrible description for 7 kyu
    but iam very satisfied solving it

  • Custom User Avatar

    I really can't understnad this problem, can someone help me please..

  • Default User Avatar

    Thanks. I think I would have understood that if the question had written out the rest of the numbers instead of "etc..."😅

  • Default User Avatar

    1 instance of have to paint a "0", 9 instances of having to paint a "1", 6 instances of having to paint a "2", etc.

  • Default User Avatar

    Someone please help me understand this question. In the example it says the frequency is nine 1's, but then proceeds to show only six 1's in the test case solution. What the heck is this question asking me to do? Could someone please explain this... I'm wasting my time just trying to understand why the example is the correct solution.
    "The digit frequencies are 1 x 0, 9 x 1, 6 x 2 etc...

    and so the method would return [1,9,6,3,0,1,1,1,1,1]"
    This output only has six 1's, and no 2's instead of 9 and 6 respectively...what are we returning??

  • Default User Avatar

    Sure, no worries. In terms of your solution, it does what it's designed to do (and passes all the tests) so is correct and valid, I found it pretty obvious what it was doing (you'd be amazed how rare this can sometimes be), so it is a good and viable solution. The only thing I would say is you don't need needless comments. Commenting that you've created an empty variable for example, doesn't add anything IMO.

    In practice, given your's has a higher complexity class than an optimal solution, then in the real world you would probably go with the more optimal solution, especially here since it's trivial to do so. That said it depends on how much of a bottleneck it actually is as to whether you'd bother (i.e. if you knew for certain this would only ever be called with arrays of 10 elements of less then optimising it would be unnecessary, just as an example). There is a saying: premature optimisation is the root of all evil.

  • Default User Avatar

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

  • Default User Avatar

    woops, replied to wrong comment, how to delete?

  • Default User Avatar

    I've ran it locally and this solution gives 3 for input [3, 4, 5, 6, 3] - which is the correct answer. How are you running the function? (I just copied and pasted into a file and ran it using Node)

  • Default User Avatar

    Hi @neilm. If I pass in the array: sumOfDifferences([3,4,5,6,3]) it appears my solution gives a different answer than this solution code does. Which is returning the correct answer here and how, since both passed the testcases? Mine returns 3, his code returns 6 for the above sample

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    Why did this kata mention 1.77 like it was important information to be used in the solution? At least I assumed it would be used. Of course, it didn't work when I tried math.round with 1.77 * y. The only answer I found online multiplied y by 1.77777 to get the answer, which is a hacky way of doing it. As a new coder, this one was a bad experience, the question is misleading. At 8kyu, we're still just trying to successfully apply the methods we're learning. Why stack deciphering a misleading question on top of that?

  • Loading more items...