Affirm - Phone screen
Anonymous User
5554

Was asked to write code for a Two player card game 'War'. I wrote the solution and executed it.
https://en.wikipedia.org/wiki/War_(card_game)
And then as a follow up, was asked to extend it for multiple players and varying number of cards.
There were two invaritants - we should treat players fairly. As in, card allocation must be random.
And the difference in the number of cards that each player has cannot be more than 1.
Didn't have time to write down the code. So I explained my solution to use a List and then a shuffle to randomize card allocation.

Number of cards : 5
Number of players 3

Player 1: 2
Player 2: 2
Player 3: 1

Got a rejection email.

Comments (5)