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.
Fixed by OP
Approved
python new test framework is required. updated in this fork
Python: Random tests are vulnerable to input modification
Kata should mention that either you don't have to worry about rounding specifics and to just use builtin rounding for your laguage, or the rounding behavior should be language agnostic and specified. The current lack of specification is unacceptable.
mmh, interesting, thx.
Ok, let's wait for more opinions.
It's in the IEEE standard, so there must be some meaning behind this (along with NaNs, Infinities and signed zero).
https://en.wikipedia.org/wiki/Rounding#Round_half_to_even
I'd like to hear from the (semi-active) kata author first. Otherwise I'm not sure... After all, it's the Python translation that introduced this inconsistency with what was expected in other languages.
mmmh... :/
Q: why the fuck languages implement such weird rounding behaviors, rather than what is usually done IRL? (meaning, round up in case of ties) Is there a reason you know about?
So, what do you think?
In JS, the original language, there are no such fixed tests and the random tests almost never generate these cases. The reference implementation uses default rounding, which is to even numbers in most languages, which maps to rounding
*2.5
s and*7.5
s to*0
s in all cases; and there're no negative numbers.Is that a problem only with python default behavior? Let me reword this: in any other language, what is the expected rounding in these cases? above only? or just as messy as python rounding default method?
Or do other languages accept both answers?
Note that I added this (for python users only) in the description:
Roundings have to be done like "in real life": 22.5 -> 25
My first solution did not pass due to the solution expected. That was why I added the sample test to clarify it. Now my first one passes the tests but the 2nd one fails as expectation got changed. Not good to have it in terms of consistency of kata.
The behaviour for numbers exactly between two multiples of 5 still isn't correctly specified.
It only says "to a nearest number", so there's an issues with the description. And since it's "to a nearest number" rather than "the nearest number", it isn't even ambiguous, it directly allows returning either.
I corrected the test so that rounding is consistent with the "real life process".
Since I know you won't ever do it yourself, I did it.
Loading more items...