Ad
  • Default User Avatar

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

  • Default User Avatar

    I usually write my code in an outside environment and save my progress onto my computer. Once i feel that it is done, I just copy and paste it into the codewars terminal!

  • Default User Avatar

    While testing for the array of size 100000, it says that I complete the test, but then it shows the "Max Buffer Reached: Too much information has been written to stdout. Process exited prematurely with a SIGKILL signal." error. I understand that the console just runs out of space, but then how has anyone finished this kata?

  • Default User Avatar

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

  • Default User Avatar

    Can someone please explain to me why this is a legal operation? I have not come across this before and am interested in knowing why this works.

  • 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!

  • Default User Avatar

    at first I had something like this, but it didn't like it when the sale percentage was 100, as it created a divide by 0 error. do you know why that wasn't the case for you?