Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I submitted my solution again without any changes, and it worked well this time.
This comment is hidden because it contains spoiler information about the solution
.
Ok thanks natan, I'll try tonight. Cheers!
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
This comment is hidden because it contains spoiler information about the solution
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 (?)
..I fixed the obvious bug and now have something that behaves like you originally described. hmm.
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.
This comment is hidden because it contains spoiler information about the solution
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.
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.
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...