bobbilyking's blog

By bobbilyking, history, 3 years ago, In English


my python solution said it had a runtime error on #5, and compared to my previous solution which gave wrong answer at #6, i really don't see a way how it could give a runtime error.


the piece of code that gives "runtime error" for #5:

if remain != 0 and bagsRn != 0: bags+=1

like what? don't understand how that could possibly give a runtime error, it's logically sound and if it gave wrong answer or exceeded time limit it would just say that... not to mention it went through 5 test cases + numerous of my own test cases to try and break it, so at the WORST it should give "wrong answer" not a runtime error

  • Vote: I like it
  • 0
  • Vote: I do not like it

3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

you have defined remain bagsRn and bags inside the loop and you are accessing it outside the loop in the end. That's why it is giving that error.