the result depends on the parity of the last unit before the dot .
In that kata , IMHO , the issue is that we understand we must made a first rounding to get an integer and after a second rounding to round to 5 if the unit of the first rounding is between 1 and 4. ( the same with values between 6 and 9 to round to the next tenth)
With an unique rounding (the second one) , no issue : if the result is >x0.0 , you round the price with x5. with a result >x5.0 you round the price to (x+1)0
I read the python doc on 'round' and was a bit surprised : "For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2)."
Strange for me , but it works as described.
Edit :
so for x0.5 it is rounded to x0 , and for x5.5 , it is rounded to x6 and in our kata you round the price to the next tenth (x+1)0
in Python roundings with xx0.5 value change from one test to another :
sometimes , it is rounded to 0 , sometimes to 1, so the final result is xx0 or xx5 , but randomly : for me it's not understandable (same issue than FArekkusu below)
I'm waiting for the python version to rank this kata , but IMHO it must be approximatively ranked as part II.
A bit more complex, but same mechanisms are involved.
A random tests on negative rounded values failed. Another try with same code has been successfull.
I saw that it was already previously araised, and recently annouced as solved.
Still an issue ?
Has anyone seen the picture announced in the description ?
I agree , yesterday I wrote a post with the same source above. I am a newbye in round function :)
Nevertheless, to avoid issues with the different modes of calculations, dont you think that an unique rounding is more appropriate.
sorry to have launched such an animated discussion :) , but I discovered the strange behaviour of round with that kata :
370+370 * 0.15 = 425.5 and round(370+370 * 0.15) = 426
270+270 * 0.15 = 310.5 and round(270+270 * 0.15) = 310
the result depends on the parity of the last unit before the dot .
In that kata , IMHO , the issue is that we understand we must made a first rounding to get an integer and after a second rounding to round to 5 if the unit of the first rounding is between 1 and 4. ( the same with values between 6 and 9 to round to the next tenth)
With an unique rounding (the second one) , no issue : if the result is >x0.0 , you round the price with x5. with a result >x5.0 you round the price to (x+1)0
Now it works , without changing my code.
I read the python doc on 'round' and was a bit surprised : "For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2)."
Strange for me , but it works as described.
Edit :
so for x0.5 it is rounded to x0 , and for x5.5 , it is rounded to x6 and in our kata you round the price to the next tenth (x+1)0
in Python roundings with xx0.5 value change from one test to another :
sometimes , it is rounded to 0 , sometimes to 1, so the final result is xx0 or xx5 , but randomly : for me it's not understandable (same issue than FArekkusu below)
2 tries to pass , because the rounding was not the same in one random test
Hi
What is the use of the 3rd parameter : size of the grid ?
The length of the 1st parameter : grid has the same value
I gave up and look at the others'solution .
Surprise : the second one is very similar to mine
Strange !
Hi
I'm waiting for the python version to rank this kata , but IMHO it must be approximatively ranked as part II.
A bit more complex, but same mechanisms are involved.
Hi
No indications about the number of random tests : timed out with 100 passed tests ?
Hi
didn't know this sum function on lists , need to explore
Forget, passed after rereading
Sorry
Hi
sorry, but unable tu understand the results of the task "buy" even with the tries of explanation below :
when you begin with harvested apple and buy orange , have you only orange at this moment or apple+orange in your stock ?
A random tests on negative rounded values failed. Another try with same code has been successfull.
I saw that it was already previously araised, and recently annouced as solved.
Still an issue ?
Why not. Pls could you write a solution corresponding to your proposal
Loading more items...