War - Puzzle Discussion


Hi everyone!
this puzzle drives me crazy…. does anyone reach 100% ?
I get a problem with test #7 (Long) : (1146 instead of 1262)
and with test #9 (other PAT) looks like infinite game ….
thanks for your answers.


yes , 15213 ( 4 yesterday ) had reached 100%


OK thanks….
I’ll keep on working on my solution !!!



je n’ai jamais réussi à passer les tests 3, 5 et 7.
J’ai refait avec un jeu de cartes le test 5. Je fini comme mon programme en “2 41” au lieu de “2 56”. Mes tas de cartes se comportent comme dans le programme (console.error).
J’ai lu tous les messages du forum. Je ne trouve plus d’idée.
Comment avancer ? Quelqu’un a t-il réussi ce test 5 ?
Merci pour votre aide.


yes … 15321 players did it …
“2 56” is test 3 … not 5 …

The only way i get “2 41” is forgetting to add cards won to my/oppenent’s deck.
don’t you know how to play this game (or haven’t you read the rules) ? :wink:


Hi dwarfie, thanks for trying to help me.
Ok for test03 and not 05. I red the rules a lot of times as also the forum. I acheaved all tests but 3, 5 and 7.
I verified again if i add cards correctly. About this, when i reproduce the example, i get the right order for both players.
But … as many of you did it, i know i have to look and look again what could be wrong with my code.

edit: ok for all tests now. i found my problem. At the end of each test i gave the number of turns of the winner instead of the total number of turns.


Thanks! I was also having this same issue because I was counting “wins” but they are irrelevant. The winner is the one with remaining card at the end of the game.

Victory Conditions

A player wins when the other player no longer has cards in their deck.


The amount of wins doesn’t determine the winner. Check the problem statement.

Victory Conditions

A player wins when the other player no longer has cards in their deck.


I think there is some defect for the rules.
" Victory Conditions:
A player wins when the other player no longer has cards in their deck."
If two player has the some cards and their are different in the some position(there is not any “war” in all of game turns). In this case, the cards in each player’s deck will be zero at some time,it can not decide which player win according to the rules of ‘Victory Conditions’.(just as test case 01).


Cards used during a turn are placed back under the turn’s winner, respecting a specific order, as it is stated in the rules.

So, at every turn’s sart, all cards are splitted between both players. Only one player can have 0 cards left.


Continuing the discussion from War - Puzzle Discussion:

Why does my project pretend to DIE ???


I am also failing only in long test. Pretty hard to debug because of the number of rounds involved in this test!


I think there is a bug in either the conditions or the long test case.
My win count is p1: 632 and p2: 630 but p2 won the last round.

I cheated to print the last winner “2 1262”.


… and after checking other solutions the Output section should be rephrased:
“Player with cards on his hands wins.”