UVa 12247 card game question AC when debugging but WA when submitting? (my code is documented)

So this is the problem. And this is the official place to debug the solution on extensive test cases. I get the accepted answers on the most upvoted test case by brianfry. (Please click the second link and you will know what I am talking about).

Here is my code(it’s documented), but when I submit it to the online judge, I get a WA. Please help.

I check if the boy (prince) has both the cards higher than those of princess than the boy is sure to win with the smallest undealt card added to his hand.

Else to make the prince win he should be able to win at least one round on his own. I check for this assuming he plays the worst he could (ie he only wins when he can’t lose) whereas the princess plays the best play always (ie wins with the smallest card that is greater than that of the prince possible and if sure to lose plays her absolute smallest card).

Go through the following link and run your source-code through the test-cases provided in the test-cases folder.

1 Like

Thank you! Those test cases helped.

Turns out if cards went all the way upto 52 in players’ hands, then my program was not printing anything. In the print loop I was using the loop initializing variable instead of ‘i’, the loop variable.