Since the past few months, I have been struggling with submitting correct solutions to problems. Most of the times I am able to devise an algorithm, write code and also pass the sample cases provided. Also i design edge cases as much as possible and try to pass them. Unfortunately, it has become a pattern where I fail some test case that I can’t find.
Can you please help with how you test solutions? Some of the questions I have no idea why they failed -
Thanks a lot,
For CHEFPTNT, your use of FILEIOS is destroying the input stream.
Comment out the reference to FILEIOS, and your solution is correct.
But your question also asks how does one find such problems.
I ran your code on various test cases on my machine, and all your answers agreed with my code.
After various experiments, I added a line
if (strlen(s) != k) exit(1);
in https://www.codechef.com/viewsolution/17467895 and it became clear you were not reading the input data correctly.
For MULTHREE, you have two versions of the code - one for small K and one for larger K.
The small K code should still be correct if you execute it with K=8. If you construct some test cases with K=8 and compare output from small K code and large K code, you should find your mistake.
Wow John, thanks a lot for your time in working through my solution and giving me valuable insight. It is very helpful. I will keep this in mind going forward.