This homework is worth 10 points.
When you finish this assignment you should be able to :
Go Fish.
An algorithm to play Go Fish
- One player is the dealer.
- Each player is dealt five cards
- The remaining cards are placed in the center of the table, face down, spread out. This is called the pool.
- The player to the left of the dealer goes first.
- At the end of each turn, play passes to the left.
- On a turn the player
- Selects another player, the victim
- Asks the victim if they have any cards of a given type
- If the victim has any cards of that type, they must hand them over to the player
- If the victim does not have any cards of that type they respond with "Go Fish"
- If the victim says "Go Fish", the player selects a card at random from the pool
- If the player receives a card they requested, from the victim or from the pool, the turn continues, otherwise it is over.
- If a player ever has all four of the same card, it is a book and all four cards are placed face up in front of the player.
- If a player ever runs out of cards, they draw five cards from the pool.
- The game is over when all 13 books have been played.
- The winner is the player, or players with the most books.
- The player may not request a card they do not hold in their hand.
Password
An algorithm to guess a password
- While the password is not found
- Pick a number n between 1 and 20
- Select n random letters, digits and symbols
- Check to see if these are the password
Tea Time
An algorithm to brew a cup of tea.
- Fill the teapot with water
- Light the largest burner on the stove
- Place the teapot on the burner
- Place two sugar cubes in a teacup.
- Place a tea bag in the teacup
- Wait until the water in the teapot boils
- Pour the water from the teapot into the teacup.
- Wait 3 minutes
- Remove the teabag
- Stir to dissolve the sugar