War - Puzzle Discussion


I'm not sure what's wrong with your input, but each player has 9 cards in that test case, not 6.
P1 has: 8C, KD, AH, QH, 3D, KD, AH, QH, 6D
P2 has: 8D, 2D, 3H, 4D, 3S, 2D, 3H, 4D, 7H

8C vs. 8D: WAR
8C, KD, AH, QH and 8D, 2D, 3H, 4D go to each "war deck"
Next they draw: 3D, 3S: WAR
3D, KD, AH, QH and 3S, 2D, 3H, 4D go to each "war deck"
Next they draw: 6D, 7H: Player 2 wins and gets everything.

Maybe there is something wrong when you read the input?

Edit: Looks like all cards which go into the war deck are duplicates. Do you possibly have a unique check somewhere?


Wow… Come on !! Thank you Garrincha !!


you are probably dealing the card in the opposite order


Not as useless as you might think !
What was your problem? Because I probably have the same.


I was confused by this game, because I did not return the 3 cards one by one (making things complex for realistic when the algo is simple).
It would have been better with clear examples :wink:


Thanks! I’ve had a problem like that a few years ago… A shame I didn’t remember that. You got me to 100%! :tada: