There are n players, and counting always starts with the folded hands of player 1. For instance, in the first round, if the rhyme has 3 syllables, player 3 would be the one to first crack their coconut into two fists. Write a program that determines the winner of the counting-out game based on the number of players and based on the number of syllables in the rhyme that is used! Input The input consists of a single test case with two numbers s (0 < s < 100) and n ( 2 ≤ n ≤ 100) denoting the number of syllables in the rhyme and the number of players, respectively. Output Output a single integer p (1 ≤p

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Problem A
Coconut Splat
Coconut Splat is one of Theta's favorite counting-out
games. It goes like this: initially, all players stand in a
circle with their hands folded together (like an intact
coconut). In clockwise order, one player touches the
hands of the other players and says the rhyme: "Co-co-
nut, Co-co-nut, Co-co-nut, Splat!" At each syllable, the
player touches a hand, and the player whose hand or
hands is touched last takes one of the following actions:
Source: WikiMedia
• If the player's hands are still folded, they are split into two fists (the coconut
is cracked in two halves). The next round starts with the fist that is the first
half of the coconut, then the second half, then going to the next player.
If a fist is touched last, the hand is turned palm down (the milk spills out).
The next round starts with the next hand in clockwise order, which could be
the other hand of the same player, or it could be the hand or folded hands
belonging to the next player.
• If a hand that is already turned palm down is touched last, the player to
whom it belongs puts the hand behind their back and this hand won't be
counted in the following rounds. The next round starts with the next hand in
clockwise order as in the previous case.
• If a player has put both of their hands behind their back, that player is out of
the game. The game ends when there is only one player left.
The hand or hands of the player doing the counting are taken into account (for
instance, the counting player touches their thigh when it would be her turn to be
touched).
There are variations of this game, for instance, some kids say "Coconut, coconut,
crack your nut!" instead, which has only 9 instead of 10 syllables as in the "Co-
co-nut, Co-co-nut, Co-co-nut, Splat!" rhyme.
There are n players, and counting always starts with the folded hands of player 1.
Transcribed Image Text:Problem A Coconut Splat Coconut Splat is one of Theta's favorite counting-out games. It goes like this: initially, all players stand in a circle with their hands folded together (like an intact coconut). In clockwise order, one player touches the hands of the other players and says the rhyme: "Co-co- nut, Co-co-nut, Co-co-nut, Splat!" At each syllable, the player touches a hand, and the player whose hand or hands is touched last takes one of the following actions: Source: WikiMedia • If the player's hands are still folded, they are split into two fists (the coconut is cracked in two halves). The next round starts with the fist that is the first half of the coconut, then the second half, then going to the next player. If a fist is touched last, the hand is turned palm down (the milk spills out). The next round starts with the next hand in clockwise order, which could be the other hand of the same player, or it could be the hand or folded hands belonging to the next player. • If a hand that is already turned palm down is touched last, the player to whom it belongs puts the hand behind their back and this hand won't be counted in the following rounds. The next round starts with the next hand in clockwise order as in the previous case. • If a player has put both of their hands behind their back, that player is out of the game. The game ends when there is only one player left. The hand or hands of the player doing the counting are taken into account (for instance, the counting player touches their thigh when it would be her turn to be touched). There are variations of this game, for instance, some kids say "Coconut, coconut, crack your nut!" instead, which has only 9 instead of 10 syllables as in the "Co- co-nut, Co-co-nut, Co-co-nut, Splat!" rhyme. There are n players, and counting always starts with the folded hands of player 1.
There are n players, and counting always starts with the folded hands of player 1.
For instance, in the first round, if the rhyme has 3 syllables, player 3 would be the
one to first crack their coconut into two fists.
Write a program that determines the winner of the counting-out game based on
the number of players and based on the number of syllables in the rhyme that is
used!
Input
The input consists of a single test case with two numbers s (0 < s ≤ 100) and n (
2 ≤ n ≤ 100) denoting the number of syllables in the rhyme and the number of
players, respectively.
Output
Output a single integer p (1 ≤p ≤n), the number of the player who is left.
Sample Input 1
Sample Output 1
10 2
Sample Input 2
10 10
Sample Input 3
1 2
↓
2
↓
2
Sample Output 2
7
Sample Output 3
2
↓
↓
Transcribed Image Text:There are n players, and counting always starts with the folded hands of player 1. For instance, in the first round, if the rhyme has 3 syllables, player 3 would be the one to first crack their coconut into two fists. Write a program that determines the winner of the counting-out game based on the number of players and based on the number of syllables in the rhyme that is used! Input The input consists of a single test case with two numbers s (0 < s ≤ 100) and n ( 2 ≤ n ≤ 100) denoting the number of syllables in the rhyme and the number of players, respectively. Output Output a single integer p (1 ≤p ≤n), the number of the player who is left. Sample Input 1 Sample Output 1 10 2 Sample Input 2 10 10 Sample Input 3 1 2 ↓ 2 ↓ 2 Sample Output 2 7 Sample Output 3 2 ↓ ↓
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education