Ad
  • Custom User Avatar

    Struggling with rounding errors on this one, wonder if there is an underlying issue or a misunderstanding on my part.

    First example
    A piece of carpet 734.3m * 194.5m @ 820.7 per square meter = 117213481.945 round half up -> 117213481.95. Test expects 117213481.94

    Second example
    A piece of carpet 998.5m * 355.1m @ 63.1 per square meter = 22373199.785 round half down -> 22373199.78. Test expects 22373199.79

    Can't even explain it through the bankers rounding employed by Python's round() method. :(

    EDIT : Escalating this to an issue. If you look at my solution, https://www.codewars.com/kata/reviews/592c6d7c82de145d90000288/groups/65b0bd84ad28ac0001f1db6d you'll see two methods, cost_of_carpet and cost_of_carpet_MP. The only difference is the order of the operands in the multiplication and yet the results are different. The one with the MP suffix fails tests, presumably because of errors in the result of intermediate calculations. So, I think the tests should allow for this rather than expecting exact figures. And if exact figures are required, it would make sense to base the results on the outputs using the Decimal class to avoid these errors.

    Using one of the examples above and reoordering the operands...

    734.3 * 194.5 * 820.7

    117213481.945

    194.5 * 734.3 * 820.7

    117213481.945

    820.7 * 734.3 * 194.5

    117213481.94500001

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    I solved this problem by deducing the test cases, because even now I do not understand what the task is about :P
    I had to spend two hours of my life on this. This task reminded me that in life you sometimes have to face such
    incomprehensible problems.
    So thanks for this reminder ;)

  • Custom User Avatar

    Fixed.

  • Custom User Avatar

    The tests don't seem to detect return value "ERROR". Consider the mock solution which returns "ERROR" all the time:

    def buy_or_sell(pairs, harvested_fruit):
        print(pairs, harvested_fruit)
        return "ERROR"
    

    This should clearly detect erroneous inputs 100% of the time, but the tests produce lines such as:

    [['Jambul', 'Juniper berry'], ['Juniper berry', 'Peach'], ['Jambul', 'Peach']] Jambul
    
    ['buy', 'buy', 'sell'] should equal 'ERROR'
    
  • Custom User Avatar

    Makes a lot more sense, thanks!

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I don't get what this third argument means.
    The definition of parse in the documentation is parse(type, str; base), so only 2 positional arguments.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Submitting a translation to this Kata.

    Lua translation

    Please review and approve

  • Default User Avatar

    random tests added

  • Default User Avatar

    Submitting a translation to this Kata.

    Lua translation

    Please review and approve

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...