Ad
  • Custom User Avatar

    @jci55,

    My guess would be dumb luck? You've raised an interesting point. I just tried with the sale_percentage set to 0 and I do get the ZeroDivisionError with my solution. But the katas solution code also has the same result.

    On the one hand, it seems odd to have sale_percentage ever be 100% since a "store" would just be giving something away for free. Google seems to think "sale" means "the exchange of a commodity for money; the action of selling something" or "a period during which a retailer sells goods at reduced prices". According to those definitions, it seems like an oxymoron to have a 100% sale.

    If a 99% sale was agreed to be the highest percentage possible, only one number would need to be changed to ensure nobody else gets one (or more) random tests with sale_percentage == 100.

    d, s = randint(1, 500), randint(0, 100)  # old
    d, s = randint(1, 500), randint(0, 99)   # new
    
    

    On the other hand, if 100% is agreed to be a valid sale_percentage, at least one new hard-coded test should be added and the kata solution must be modified (since it also raises a ZeroDivisionError).

    Hopefully that helps to answer your question. Thanks for the comment!