Ad
  • Custom User Avatar

    Haskell translation

    A language-specific snippet was added to the end of description.

  • Custom User Avatar

    python new test framework is required. updated in this fork

  • 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