Four players want to play a game of cards. There are N cards with them. They can only play a game if they can distribute the cards equally to each other. They follow a special way of distributing cards.
Consider the following distribution method:
Every other card is given to respective player.
The remaining cards are then shuffled by reversing.
If there’s any cards left, start from step 1 until there’s none left.
For the ease of understanding let’s name our players “Player 1 , Player 2 , Player 3 , Player 4”.
Now you are asked to write a program that will distribute the cards to each player as mentioned above and print the hands of each player.
The number of cards (N) is not less than 4 and not more than 52. N will be taken as input in the first line. N is a multiple of 4. N has to be a multiple of 4 because else they can’t equally distribute cards among them. In that case the game is forfeit. A deck of cards have 4 types of cards. They are Spades, Clubs, Hearts and Diamonds. Let’s consider Spades, Clubs, Hearts and Diamonds as S , C , H and D. Each type of cards have 13 different cards, they are Ace, King, Queen, Jack and number cards from 2 to 10. Consider Ace, King, Queen, Jack as A, K, Q, J. Your program will take card names as input as followed (card name-card type). EG: A-S (Which means Ace of Spades.)
Print distributed cards among the players as shown in the sample output.
8 A-S 10-H 2-S 5-D K-C 8-D 10-S K-H
Player 1 : A-S K-H Player 2 : 2-S 5-D Player 3 : K-C 10-H Player 4 : 10-S 8-D
Problem Setter: Niloy Sarker