Ad
  • Custom User Avatar
  • Custom User Avatar

    But I think it's a good real world example to practice on

    Atleast in my world, things don't have negative price and niether the quantity is negative. :D

    How do I prevent the user from doing that? Is it necessary? Is it possible to cheat the (random) tests with that?

    Yes, it is necessary, otherwise I'll pass the modified argument to reference solution which would destroy randomness, and then I can hard-code the fixed tests solution.

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks for your feedback on my first kata! :)

    • You're right, would you add input validation as requirement to make the kata more interesting or remove it to keep it simple?
    • How would I do that with chai (noob here)? Would you still keep rounding to 2 decimals though?
    • How do I prevent the user from doing that? Is it necessary? Is it possible to cheat the (random) tests with that?
    • It's not very innovative, I give you that. But I think it's a good real world example to practice on
  • Custom User Avatar
    • Input validation is not mentioned anywhere, and should be removed
    • The actual/expected values should be compared for approximate equality
    • The user can modify the input
    • Summing a list of numbers is not interesting or new kata idea
  • Custom User Avatar

    Check if that division is messing up the numbers. Maybe you need another kind of division, like integer divison

  • Custom User Avatar
  • Custom User Avatar

    Author or power user available to approve this translation?

  • Custom User Avatar

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

  • Custom User Avatar

    Something like this should be reportable... or better: not even possible if the author would have used random tests

  • Default User Avatar

    I'm happy that you passed!

  • Custom User Avatar

    I found what was missing and completed my solution 🙂
    Hint: was a slight oversight in my while condition which allowed me to exit earlier.

  • Custom User Avatar

    So you're saying the problem is my solution is actually too slow? I'd have 0 clue how to get it faster 🤔, I already optimized it some times.

  • Default User Avatar

    I tried a few solutions, one of the fastest took 1500ms.

  • Custom User Avatar

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