Ad
  • Default User Avatar
  • Default User Avatar

    There are a lot of "solutions" on here that should be disqualified because they rely on the sum of 1-9 being 45 (which clearly fails if every number in the array is just set to 5). Definitely needs better testing.

  • Default User Avatar

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

  • Default User Avatar

    Had to lean pretty heavily on Google Translate to understand what you were saying, but I appreciate your explanation. Makes much more sense now :)

  • Default User Avatar

    So what you need to realize is that these three operations did NOT take 87ms/109ms/150ms. What took that long was initializing the python runtime and executing your code.

    (I mean ... seriously ... think about it ... are you trying to say your computer can only do ~10 multiplication operations per second? I think computers exceeded that level of performance in the 1940s.)

    The time to negate an integer is so fast that it is borderline impossible to measure. You'd need to write a VERY carefully written benchmark program that repeats this operation many many times, carefully removes the time for the necessary jump operations, and never gets switched off the CPU by the OS before you could even begin to claim that you've acquired an accurate measurement of performance.

  • Default User Avatar

    This hurts. For so many reasons. At the bare minimum, the final if statement should have just been:

    if(a && b && c && d ... )

    This is a submission I would expect to see from a CS101 course.