Several people play with a 6-sided die and take alternating turns.
In each turn the player starts by throwing the die, and the player who throws a '6' wins immediately.
Obviously, each turn entails a one in six chance of winning.
As soon as one player wins, the game ends and all other players lose the game.
The game is not fair. For example, in a two-player version, the first player is expected to win 6 out of 11 games.
In our problem playerCount mathematicians decided to play a fair version of the
game. After a while, they came up with a solution -- they will not take alternating turns. Instead,
they will find and follow a different sequence of turns that will make the game fair.
(See notes for a precise definition.)
For simplicity, assume that the players are assigned the first playerCount letters
of the alphabet. Then the sequence of turns can be represented as an infinite string
of letters. Out of all fair sequences we will be interested in the lexicographically
You are given an int playerCount, and an int turnNumber.
Your method should find the lexicographically smallest fair sequence of moves for playerCount
players, and return a one-character String containing the
player that has to play in the turn turnNumber. Turns are numbered starting from 1.
If there is no fair sequence of moves for playerCount players, return an empty string