Feel free to send your feedback or ask some help here!
Hi, I had some problem understanding the rules.
The rule said that: If the two cards played are of equal value, then there is a âwarâ. First, both players place the three next cards of their pile face down. Then they go back to step 1 to decide who is going to win the war (several âwarsâ can be chained). As soon as a player wins a âwarâ, the winner adds all the cards from the âwarâ to their deck.
But, in the example:
For example, if the card distribution is the following:
Player 1 : 10D 9S 8D KH 7D 5H 6S
Player 2 : 10H 7H 5C QC 2C 4H 6D
Then after one game turn, it will be:
Player 1 : 5H 6S 10D 9S 8D KH 7D 10H 7H 5C QC 2C
Player 2 : 4H 6D
They played the war with 4 cards each.
Player 1: 9S 8D KH 7D
Player 2: 7H 5C QC 2C
So, I need 3 o 4 cards in a War? O Iâm getting this wrong?
Hi
3 cards face down + 1 card face up (this is the step 1)
Je passe tous les tests, sauf 'un autre PAT".
En dĂ©taillant chaque pli, je nâaboutis effectivement pas dans une situation de âPATâ : le joueur 1 gagne aprĂšs 40 manches.
Ai-je raté une subtilité ?
I pass all the tests, except âanother PATâ.
When I detail the battle I do not finish in a âPATâ situation : player 1 wins after 40 rounds.
Have I mist something ?
Bonjour,
a priori jâai le meme probleme
It is easy to misunderstand the rules and hard to debug any discrepancies since you only get to compare the final results, anything can go wrong somewhere in between (unless there is some debug mode I am unaware of).
What is the order of the three cards face down during the battle ?
Are they put one after each other (the order of the cards is unchanged ) ?
Or are they put in one lot (the order is inverted) ?
Thank you.
Quel est lâordre des trois cartes Ă dĂ©fausser lors dâune bataille ?
Sont-elles mises lâune aprĂšs lâautre (lâodre des cartes est inchangĂ©) ?
Ou les trois cartes sont-elles mises groupĂ©es (lâordre est inversĂ©) ?
Merci.
I had a problem with both of the PAT tests and the mistake I did was that if one and only one player ran out of cards during a war - the other player won. This was apparently a PAT case, which is far from obvious. The quote: âThere are no winners in warâ does not fit this game
But frankly this doesnât sound like your problem, because you passed one of the PAT tests.
The order of the face down cards during a war is the same as they where in the main deck. The winner always takes the cards from player 1 first, no matter who won. Does it make sense?
I agree : in case only one player runs out of cards during a war shouldnât end up with a PAT. Still I did coded it right to have a PAT result for the eighth test.
I tried it with inverting the three faced down cards during a battle : I pass the last test ⊠but I get it wrong at the eighth one now !
Jâai finalement trouvĂ© mon erreur !
Je ne gĂ©rais pas le cas oĂč un joueur jpuais sa derniĂšre carte, mais remportait le pli.
Merci Ă tous.
I found my mistake finally !
I wasnât managing when a player plays its last card, but can continue playing by winning the fold.
Thank you to all.
Je suis perdu: lorsque je valide mon code (les tests dâentrainement tous validĂ©s sauf le test long), je mâaperçois que tous les tests sont validĂ©s sauf le test long (jusque la rien dâaberrant) mais aussi le tout premier (âet ça câest loucheâ comme dirait ma grand mĂšre).
Il doit donc y avoir un cas particulier qui me fait planter mais je nâarrive pas Ă le recrĂ©er en jeu de test et je nâai pas le courage de regarder les 1200 et quelques manches du test âpartie longueâ. Quelquâun Ă une idĂ©e pour me dĂ©bloquer?
merci
I am lost: Iâve sent a solution (beating every training tests but the âlong gameâ) and itâs validating the long test (nothing strange here) but also the first case (3 cards).
There must be a particular case I am not considering but I canât understand which one and I donât have the motivation to look the 1200 hands od the âlong gameâ test to understand my mistake. Anyone has an idea to unlock me?
Thanks
Bonjour LaFayette,
Jâai eu le mĂȘme problĂšme Ă un certain moment. Pour ma part, câĂ©tait un problĂšme dâun mauvais calcul du nombre de coup jouĂ© total. Pour corriger ton algorithme, assure-toi que ton compteur de nombre de coup est bien efficace. Sinon assure-toi aussi de faire attention Ă ce que tu mets dans les else (si tu les utilises).
Si ton premier test nâest pas valide je te conseille de corriger celui-ci en premier au lieu de la partie longue (gĂ©rer les erreurs sera plus facile).
JâespĂšre tâaider, si ton problĂšme persiste, dis-moi quand quel language tu code et jâessaierai de tâaider.
Bonne chance!
Yeah, I have the same problem that you two had. I donât think I messed up the counter because I got PAT for the âLong Gameâ test case. I also get 2 2138 on the first âPATâ case. If you or anyone got something similar, speak up!
Ouais, jâai le mĂȘme problĂšme que vous deux. Je ne pense pas que jâai gĂąchĂ© le compteur parce que jâai obtenu PAT pour le âLong Gameâ cas de test. Je reçois Ă©galement 2 2138 sur le premier cas âPATâ. Si vous ou quelquâun avez quelque chose de similaire, dites-le!
If anyone who works for CodinGame sees this, please edit the problem statement to make this a bit clearer.
I had been failing test cases 7 and 8 because of chained wars. The problem statement clearly says, âWhen a player wins a battle, they put back the cards at the bottom of their deck in a precise order. First the cards from the first player, then the one from the second player (for a âwarâ, all the cards from the first player then all the cards from the second player).â I interpreted this as, taking the cards from the p1 both wars, then from p2 in both wars. As you can see, the problem statement says ALL the cards from the first player, then the second.
If you change your code to give the players the cards from the first war, then the second war, and so on, it should work. Hopefully someone important sees this!
Hi, according to your comment â3 cards face down + 1 card face upâ and the example i have a question and maybe you can help me out.
These are the decks:
Player 1 : 10D 9S 8D KH 7D 5H 6S
Player 2 : 10H 7H 5C QC 2C 4H 6D
For Player One:
The 10D and 10H cause a war to happen so, the next three cards are â10D 9S 8Dâ or â9S 8D KHâ?? I am very confused.
So basically my question is, do you include the â10Dâ in the first 3 cards?
When the cards of the first and second player are equal ( == ), the battle start. When you start a battle, you got to remember that it is alway going the cards of the FIRST PLAYER that is going to be add in the deck of the winner, no matter which player wins the battle. Then, for the first player you take the first card (the one that start the battle), + the 3 next, then the next one is going to decide who wins the battle and this card is going to be add in the winnerâs deck too. In one single battle, 10 cards are going to move into the winnerâs deck and you got to be sure to follow the right orders (cards of first player then the cards of the second player)
Example:
First player: (10H<âstart the battle) (1H 2H 3H)<-- card for win 4H <âcard that fight 5H (other card)
Second player: 10D 1D 2D 3D 5D 6D
In this case, the winnin pack going to be 10H 1H 2H 3H 4H 10D 1D 2D 3D 5D.
The second player winâs the battle (5D > 4H)
The result is going to be only 5H for first player and 6D 10H 1H 2H 3H 4H 10D 1D 2D 3D 5D for the second player.
So, important, you have to remember (it is the same for a single fight), that when a player wins a fight or a battle, you got to alway put the card of the first player in the winnerâs deck and at the end of the list ( or arrays). This is wrriten in rules.
Good luck to you all, hope i help.
Like i said, if the problem is persitent show your code and im going to check what is wrong.
â9S 8D KHâ
I donât get it! What are the â1â cards?
They are not aces (already four aces in the game), but they seem to be superior to kingsâŠ
What are we supposed to do with them?
There is no 1 card in the game.