Problem 80 - Duel Chances - Python

Back to General discussions forum

rafael.adorna     2022-02-12 19:48:17
User avatar

I'm just leaving this here for whoever is trying to attemp this task in Python... Please remember that round has this logic implemented: https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex x rounded to n digits, rounding half to even. If n is omitted, it defaults to 0.

In my particular case, I was getting these values and round "rounded" them but they were different from the expected output: 46.153846153846146 46 62.5 62

Please keep this in mind when implementing the solution in Python

Rodion (admin)     2022-02-13 07:58:53
User avatar

That's curious you haven't encountered this earlier in other tasks using rounding :)

With Python one should first set proper rounding mode, before using it - or round "manually" with int(x+0.5)...

Please login and solve 5 problems to be able to post at forum