Card War
Two players hold decks of numbered cards, and alice and bob list their cards from the top of the deck to the bottom. In each round both reveal their top card. The higher card wins, and its owner puts both cards at the bottom of their own deck: their own card first, then the other card. If the two cards are equal, both are removed from the game.
The game stops when a deck is empty or after rounds rounds, whichever comes first. Return the decks at the end as [alice_deck, bob_deck], each from top to bottom.
Example 1
Bob wins round 1 and puts his 5 and then the 2 at the bottom. Alice wins rounds 2 and 3, and the game stops after 3 rounds.
Example 2
The two 4s are removed, and the game stops after its single round.
Constraints
0 <= len(alice), len(bob) <= 12- every card is from
1to20 0 <= rounds <= 200
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.