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?
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
solved 100%, but too long to debug. The difficulty should be in the problem, not in long data to read and deal with truncated debug info if there are too many rows.
Here is something I have learned. You can play the cards in the reverse order and some test cases will pass. You can put cards from a War into the deck in the wrong order and still pass many of the tests.
So just because many of the tests pass does not mean you are moving cards around in the correct order.
I have no clue about this puzzle. How do the wars work? In what order are the cards from each player added into the deck? I have so many questions! The rules of this puzzle are so vague.
Yet more confusion from this puzzle’s description:
“Special cases:
If a player runs out of cards during a “war” (when giving up the three cards or when doing the battle), then the game ends and both players are placed equally first.”
“Victory Conditions
A player wins when the other player no longer has cards in their deck.”
I am not playing on words. I am reading them literally.
The one describing the victory condition says "A player wins when the other player no longer has cards in their deck.”
That is only part of the victory condition, because if that happens during a war, then “both players are placed equally first” which I suppose means a draw. A draw is not victory.
Correct would be “A player wins when the other player runs out of cards outside of a war.” or “A player wins when the other player runs out of cards after playing the first card of the round.”
This is not a play on words. This is literally what it says. Please don’t take it personally.
If a player runs out of cards while placing the 3 face down after a matching pair, does the player lose or is it a draw?
As for me, I’ve figured this out (finally). I’m just saying it would take a minimum of effort for a couple of minutes to reword it, and would seem to be the duty of the creator. This “special case” is not shown in the short example.
I’ll concede this isn’t the best worded puzzle on CG. Possibly they’d take your suggestions, too.
But you might want to realize that as far as example and tests go, it’s got all you can ask for: the special case seems to be explicitly verified in one of the explicit PAT cases, and the statenemt couldn’t possibly demonstrate all ending types in a single example.
So not sure if anyone else did this but I think I saw a comment above mention it. I was tallying the amount of times each player one and was using that to determine who was winning when I should have just checked while player had no cards left. This left me getting the result 1 1262 for the Long game vs 2 1262. Just thought i’d put that out there in case anyone else experienced this too