Question

#The game HORSE is a popular basketball shooting game. #It can be played with any number...



#The game HORSE is a popular basketball shooting game.

#It can be played with any number of players. One-by-one,

#each player takes a shot from anywhere they want. If they

#make the shot, the next person must make the same shot.

#If they do not, they receive a letter: H, then O, then R,

#then S, then E. Once a player receives all 5 letters, they

#are out of the game.

#

#The game continues until all but one player has all five

#letters.

#

#Write a function called check_horse_winner. This function

#will take as input a tuple of at least two, but potentially

#more, strings. 

#

#check_horse_winner should return the following:

#

# - If only one player is left with fewer than 5 letters,

#   return "Player X wins!", where X is the index of the

#   player in the list (which could be 0).

# - If more than one player has fewer than 5 letters,

#   return "Players X, Y: keep playing!", where X, Y, and

#   potentially more numbers are the indices of all players

#   who have not yet been eliminated.

# - If no player has 5 letters, return "Everyone: keep

#   playing!"

#Write your function here!


#Below are some lines of code that will test your function.

#You can change the value of the variable(s) to test your

#function with different inputs.

#

#If your function works correctly, this will originally

#print:

#Everyone: keep playing!

#Players 1, 2: keep playing!

#Player 2 wins!

print(check_horse_winner(("HOR", "HORS", "H", "HO")))

print(check_horse_winner(("HORSE", "HOR", "HORS", "HORSE")))

print(check_horse_winner(("HORSE", "HORSE", "HORS", "HORSE")))

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def check_horse_winner(players):
        alive = [str(i) for (i, x) in enumerate(players) if len(x) != 5]
        if len(alive) == len(players):
                return 'Everyone: keep playing!'
        if len(alive) == 1:
                return 'Player ' + alive[0] + ' wins!'

        return 'Players ' + ', '.join(alive) + ': keep playing!'


print(check_horse_winner(("HOR", "HORS", "H", "HO")))
print(check_horse_winner(("HORSE", "HOR", "HORS", "HORSE")))
print(check_horse_winner(("HORSE", "HORSE", "HORS", "HORSE")))

Please upvote, as i have given the exact answer as asked in question. Still in case of any concerns in code, let me know in comments. Thanks!

Add a comment
Know the answer?
Add Answer to:
#The game HORSE is a popular basketball shooting game. #It can be played with any number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Two player Dice game In C++ The game of ancient game of horse, not the basketball...

    Two player Dice game In C++ The game of ancient game of horse, not the basketball version, is a two player game in which the first player to reach a score of 100 wins. Players take alternating turns. On each player’s turn he/she rolls a six-sided dice. After each roll: a. If the player rolls a 3-6 then he/she can either Roll again or Hold. If the player holds then the player gets all of the points summed up during...

  • Monshimout is a game from the Cheyenne people and played by women. It could be played...

    Monshimout is a game from the Cheyenne people and played by women. It could be played by two or more players, and if played by more than two, then the players divided into two equal teams. Game equipment consisted of five plum stones and a basket made of woven grass or willow twigs. The basket measured 3-4 inches deep, 8 inches across at the top, and almost 1/2 inch thick. The plum stones were left plain on one side, but...

  • C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an...

    C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an elimination dice game. It can be played by any number of players, but it is ideal to have three or more players. Wild, Wild, West! Requires the use of two dice. At the start of the game, each player receives a paper that will track the number of lives that player has. Each player starts the game with 6 lives. In the first round,...

  • You will create a PYTHON program for Tic-Tac-Toe game. Tic-Tac-Toe is normally played with two people....

    You will create a PYTHON program for Tic-Tac-Toe game. Tic-Tac-Toe is normally played with two people. One player is X and the other player is O. Players take turns placing their X or O. If a player gets three of his/her marks on the board in a row, column, or diagonal, he/she wins. When the board fills up with neither player winning, the game ends in a draw 1) Player 1 VS Player 2: Two players are playing the game...

  • This program should be in c++. Rock Paper Scissors: This game is played by children and...

    This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...

  • critically analysis is required for this pasage Using the Topic Material "Game Theory," discuss your perspective...

    critically analysis is required for this pasage Using the Topic Material "Game Theory," discuss your perspective on the use of game theory. How do "Nash equilibrium" and the idea of one "player" impacting another "player" within an organization affect the economic decisions and growth of an organization? The use of Game Theory happens continuously throughout our daily lives, as we make decisions. Anytime we make a decision that affects another player (person or group), this is Game Theory in play....

  • passage require analysis and breakdown Using the Topic Material "Game Theory," discuss your perspective on the...

    passage require analysis and breakdown Using the Topic Material "Game Theory," discuss your perspective on the use of game theory. How do "Nash equilibrium" and the idea of one "player" impacting another "player" within an organization affect the economic decisions and growth of an organization? The use of Game Theory happens continuously throughout our daily lives, as we make decisions. Anytime we make a decision that affects another player (person or group), this is Game Theory in play. The essence...

  • War—A Card game Playing cards are used in many computer games, including versions of such classic...

    War—A Card game Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. War:    Deal two Cards—one for the computer and one for the player—and determine the higher card, then display a message indicating whether the cards are equal, the computer won, or the player won. (Playing cards are considered equal when they have the same value, no matter what their suit is.) For this game, assume the Ace (value 1) is...

  • C++ Hangman (game) In this project, you are required to implement a program that can play...

    C++ Hangman (game) In this project, you are required to implement a program that can play the hangman game with the user. The hangman game is described in https://en.wikipedia.org/wiki/Hangman_(game) . Your program should support the following functionality: - Randomly select a word from a dictionary -- this dictionary should be stored in an ASCII text file (the format is up to you). The program then provides the information about the number of letters in this word for the user to...

  • Program 4: C++ The Game of War The game of war is a card game played by children and budding comp...

    Program 4: C++ The Game of War The game of war is a card game played by children and budding computer scientists. From Wikipedia: The objective of the game is to win all cards [Source: Wikipedia]. There are different interpretations on how to play The Game of War, so we will specify our SMU rules below: 1) 52 cards are shuffled and split evenly amongst two players (26 each) a. The 26 cards are placed into a “to play” pile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT