stone game - wrong Answer

Can someone please tell me where i went wrong? It gives the required output as the test case but it gave me a wrong answer when submitted.
Here is the link to my code :

You have to test your code for more inputs than just those in problem statement, I tried

1 2

and your code printed ALICE, but in first move Alice can remove stones and in second move Bob can remove stones too, so Bob is the winner :wink:

the result would be ALICE because it is said that atleast i stones are removed from the ith pile.So,after Bob ALICE would have one more chance (which is the last one here).So,the winner would be ALICE.

@roshi answer would be ‘BOB’ as from 2nd pile 2 stones would have to be removes. it is given that " removes exactly i stones from it" and not atleast i are removed. hence your code is wrong for “1 2”. the reaqson you are getting WA is because you havent considered the case when stones can a removed from a single pile multiple times. eg if pile 2 has 4 stones, after 1st removal it has 2, you can again remove 2 from this pile again!! so you need to change your code to handle this.

thank you.It worked :slight_smile: