Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 3892076?s=100

    Commenting code which does magic now considered a bad practice? By who?
    If it's math magic, it is still magic.
    Names trick does not help here at all, btw.

  • 17221813?s=100

    Are you trolling? This is a one line function which is 8 characters long. We have no control over the function name/ file name. Explaining the programming language/ framework, or in this example, plain old math, is considered a bad practice.

    You may argue that because 'it is helpful to translate the meaning of some obscure argument or return value into something that’s readable.' Or that 'when [the code] is part of the standard library, or incode that you cannot alter, then a helpful clarifying comment can be useful.'

    But to explain math to a future programmer in the comments would be considered harmful noise. This is because important comments will just be ignored after a while.

    The adage: 'Don’t Use a Comment When You Can Use a Function or a Variable' is applicable here. I convert this block to english like so: 'To sum the row of odd numbers, I cube the row index'. I cannot see any value in adding a comment here.

  • 3892076?s=100

    Yes, indeed. Do not write comments where code is clean.


    How can clean code in this example explain anything? Why you should believe this code is right?
    Another people said so?

  • 17221813?s=100

    Read clean code. It recommends the exact opposite.

  • 3892076?s=100

    To make people who read you solution to understand it.

    Not a best solution with a good explanation in real world worth much more, than ideal solution
    with no explanation.

    Supporting projects with lack of comments is always a pain. Try it once to feel it.

  • 3484906?s=100
  • 3892076?s=100

    "Best Practices" would be to explain solution in comment.

  • Profile pic

    I'm not clear on the instructions and the purpose of calculating the winning number for each person, do we have to sort each winning number-person pair, and then return the name whose index= n? If someone can paraphrase the whole instruction more clearly, I'd really appreciate it

  • 17221813?s=100

    Thank you for this. I recommend naming the variables explicitly next time. For example naming n what ever that was (index_of_winner?) and we (weights?). Such short names are advised against in books such as clean code because it unnecessarily obfuscates the codes meaning

  • 17221813?s=100

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

  • 17221813?s=100
  • 2960938?s=100

    From a mathematical standpoint, returning zero is not that bad. Only if the calculation really was wrong you should throw an error (inserting letters for example)

  • 9937295?s=100

    fair enough :

    @renjia93 , I hereby register my opinion that it's wierd to expect 0 in above case.

    just an opinion of course :)

  • 17221813?s=100


    We expect 0 in this case because that was the challenge set by @renjia93 for this kumite. Namely

    "if no positive number in array, return 0."

  • 9937295?s=100
      it("test3", function(){
        var list = [null, -2];
        Test.assertEquals(getMin(list), 0, "test fails");

    why do we expect 0 in this case?

  • Loading more items...