Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Duck Duck Boot! Filename: duckboot Jimmy\'s got a lot of friends. However, he li

ID: 3836626 • Letter: D

Question

Duck Duck Boot!

Filename: duckboot

Jimmy's got a lot of friends. However, he likes to play this game he calls "Duck Duck Boot." It's a very simple game. He starts behind his best friend and walks around his circle of gathered friends in a clockwise direction and to each friend (beginning with his best friend) either yells "Duck" and swings, or he gives them the boot. If he gives them the boot they become agitated and then they never talk to Jimmy again (note that this also means they immediately leave the circle and are no longer a part of the game). After calling “Duck” or after booting his friend Jimmy will continue from where he is in the circle. He will not start over from his best friend’s position. Now, to be fair Jimmy has decided that there must be at least one “Duck” before a boot.

The Problem:

Jimmy's mom is very concerned (she seems to recall that his birthday might be coming up) and she wants to know if Jimmy will have any friends after he finishes playing this game. She has hired you to figure out how many friends he will have after he finishes playing this game.

The Input:

The first line will contain a positive integer, g, indicating the number of games Jimmy's mom wants you to check.

For each game, there will be a line containing a single integer, f (f > 0), which represents the number of friends that Jimmy has before he starts playing the game (the first friend in the list is Jimmy's best friend). Each of the following f lines will contain one of his friend's names (up to 20 letters) in the order that they stand in the circle (clockwise order). All of Jimmy’s friends will have a unique name and will contain only one capital letter at the beginning of his/her name (the rest of the letters will be lowercase). On the next line there is an integer, r (0 < r 2000), and an integer, d (0 < d 2000), separated by a single space where r represents the number of rounds that Jimmy plays with this group of friends (note that if he has no friends left he stops playing) and d represents the number of times he says "Duck" before he gives someone the boot. Jimmy is a repetitive boy and once he picks the number of times within a game that he’s going to say duck before he says boot he will always stick with it.

The Output:

For each game, determine how many friends Jimmy has left after he finishes the last round of "Duck Duck Boot". Begin the output for each game with a header "Game i:" where i begins with 1 and increases for each game. After this print the list of Jimmy's remaining friends, one per line by itself (no leading or trailing spaces), in alphabetical order. If Jimmy has no friends left at the end of the game output "Jimmy has friends no more." After each game output a blank line.

19

Sample Input:

2
3
Bob Cody John 22
8 Carol Casey Nick Kirsten Ben

Bo Billy Heather 34

Sample Output:

Game 1: Cody

Explanation / Answer

no_of_games = int(input())
no_of_friends_list = []
friends_names = []
r_vales = []
d_values = []
for i in range(no_of_games):
x = int(input())
no_of_friends_list.append(x)
tmp_list = []
for i in range(x):
tmp_list.append(input())
friends_names.append(tmp_list)
r_vales.append(int(input()))
d_values.append(int(input()))
  
no_of_friends_list_temp = no_of_friends_list
friends_names_temp = friends_names
r_vales_temp = r_vales
d_values_temp = d_values
for i in range(no_of_games):
for j in range(r_vales_temp[i]):
# print(d_values_temp[i])
# print(len(friends_names_temp[i]))
if d_values_temp[i] > len(friends_names_temp[i]):
del friends_names_temp[i][d_values_temp[i] - len(friends_names_temp)]
elif d_values_temp[i] == len(friends_names_temp[i]):
del friends_names_temp[i][0]
else:
del friends_names_temp[i][d_values_temp[i]]

for i in range(len(friends_names_temp)):
print("Game " + str(i+1) + str([val for val in friends_names_temp[i]]))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote