A group of friends are standing in a circle playing a game. They proceed around the circle, chanting the rhyme and pointing to the next person (clockwise) on each word. When the rhyme finishes whoever is being pointed at leaves the circles. Then they start again, pointing where they left off, and the game continues until only one person is left.
The version of the rhyme they are using is
Eeny, meeny, miny, moe,
Catch a tiger by the toe.
If he hollers, let him go,
Eeny, meeny, miny, moe.
Write a program, which given the number of friends and the length of the rhyme, can determine who wins.
Taken from the 2004 Informatics Olympiad.
Click here to view all the competition tasks.