Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 friends

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 Jimmys 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 hes 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.

20

Sample Input:

2

3

Bob

Cody

John

2 2

8

Carol

Casey

Nick

Kirsten

Ben

Bo

Billy

Heather

3 4

Sample Output:

Game 1:

Cody

Game 2:

Billy

Bo

Carol

Kirsten

Nick

NEEDED IN C LANGUAGE!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

=+c) The change in your pocket by year minted. Section 22.2

Answered: 1 week ago