this is clean i was thinking using the range function too
yep, but the inputs are too small in the test suite (at least when I posted this), so that worked with py3 too, while it's incorrect.
This is correct if you're using python 2 since it will use floordiv and not truediv.
This solution is actually wrong, due to potential floating point errors. See the fork.
Correct version here.
This comment is hidden because it contains spoiler information about the solution
That's definitively faster: O(1) (More math than informatics, though)
Loading collection data...
this is clean i was thinking using the range function too
yep, but the inputs are too small in the test suite (at least when I posted this), so that worked with py3 too, while it's incorrect.
This is correct if you're using python 2 since it will use floordiv and not truediv.
This solution is actually wrong, due to potential floating point errors. See the fork.
Correct version here.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
That's definitively faster: O(1)
(More math than informatics, though)