Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    Read clean code. It recommends the exact opposite.

  • Custom User Avatar

    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

  • Custom User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    Hey.

    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."

  • Custom User Avatar

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