Ad
  • Custom User Avatar

    I submitted my solution again without any changes, and it worked well this time.

  • Custom User Avatar

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

  • Default User Avatar

    .

  • Custom User Avatar

    Ok thanks natan, I'll try tonight. Cheers!

  • Default User Avatar

    Right, yeah. Well. See if you can make it use integer math and if that works out for you.
    js number is a float, but float is able to represent integers.
    what introduces non-integers is division, so whenever you do division you have to immediately bring it back into an integer value. continuing to use the result before doing this will likely introduce rounding errors into your results

  • Custom User Avatar

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

  • Default User Avatar

    If printing out the remaining time after hours and minutes, I get:

    remaining: 59.99999999999939

    So, I suppose the "advice" then is that the entire problem is solvable with integer math and that you should avoid leaning on float in ways where you can introduce rounding errors.
    Maybe that's vague for javascript where you're stuck with the float type, but I assume that integer division is still something that can be carried out correctly (?)

  • Default User Avatar

    ..I fixed the obvious bug and now have something that behaves like you originally described. hmm.

  • Default User Avatar

    I see one thing that's really really wrong and unrelated to rounding.
    Maybe you even posted a wrong version of your code? This won't be off by one second, it'll be more wrong than that.

  • Custom User Avatar

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

  • Default User Avatar

    It definitely shouldn't be ambiguous because the inputs are int - the problem is solvable without ever using floats.... except in javascript which in its infinite wisdom doesn't have an integer type. Still, it's possible to do correct integer math in javascript... I think? So something's got to be wrong with what you're doing.

  • Custom User Avatar

    I did Math.floor on minutes and seconds only at the end, to keep all the decimal part of the numbers during the process, but it doesn't work for one test only and for 1 second only.
    I don't understand why.

  • Default User Avatar

    Maybe you're truncating too early or doing something else wrong. You're supposed to floor, that's in the instructions. That's the one thing you know isn't the cause.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Loading more items...