Simple card game X37806


Statement
 

pdf   zip   main.py

html

Using the Card, Deck, and Hand class definitions, write a Player class, a Game class, and a program to play a simple card game with any number of players.

In this simple card game, each of the players draws a card from a shuffled deck. Whoever has the highest card wins. Cards are compared first by suit, then by rank. Spades beat Hearts, which beat Diamonds, which in turn beat Clubs. Within a same suit, King beat Queen, which in turn beat Jack, which beat 10 down through 2, which beat Ace.

Input

The input consist of a positive integer n, the number of players, followed by a shuffled deck of cards.

Output

For each player, print the card drawn by the player, followed by the winner of the game.

Precondition

The number of cards in the shuffled deck is not less than the number of players.

Public test cases
  • Input

    5
    8 of Clubs
    7 of Diamonds
    8 of Hearts
    Jack of Clubs
    Queen of Diamonds
    6 of Clubs
    2 of Diamonds
    King of Spades
    8 of Spades
    Jack of Diamonds
    

    Output

    Player 1 draws Jack of Diamonds
    Player 2 draws 8 of Spades
    Player 3 draws King of Spades
    Player 4 draws 2 of Diamonds
    Player 5 draws 6 of Clubs
    Player 3 wins with King of Spades
    
  • Input

    1
    8 of Clubs
    7 of Diamonds
    8 of Hearts
    Jack of Clubs
    Queen of Diamonds
    6 of Clubs
    2 of Diamonds
    King of Spades
    8 of Spades
    Jack of Diamonds
    

    Output

    Player 1 draws Jack of Diamonds
    Player 1 wins with Jack of Diamonds
    
  • Input

    0
    8 of Clubs
    7 of Diamonds
    8 of Hearts
    Jack of Clubs
    Queen of Diamonds
    6 of Clubs
    2 of Diamonds
    King of Spades
    8 of Spades
    Jack of Diamonds
    

    Output

    None wins with None
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    Python
    User solutions
    Python