Your question is Card Game War Implementation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement a simulator for a two-player War game used in a Workiva collaborative review prototype. Each player's deck is represented from top to bottom, and the function must return the winning player.
On each round, both players draw their top card. The player with the higher rank wins all cards played in that battle and places them at the bottom of their deck in play order. If the ranks are equal, each player must place three face-down cards followed by one face-up card. Compare the new face-up cards, repeating the process if they tie again. A player who cannot provide all three face-down cards and a face-up card loses immediately.
Implement war_winner(deck1, deck2), where deck1 and deck2 are lists of integers ordered from top to bottom. Return integer 1 if player 1 wins, or 2 if player 2 wins. Card integers represent ranks, so duplicate values are allowed. Inputs are guaranteed to produce a terminating game.
def war_winner(deck1, deck2):