Andy wants to play a game with his little brother, Bob. The game starts with an array of distinct integers and the rules are as follows:
Andy and Bob play games. Given the initial array for each game, find and print the name of the winner on a new line. If Andy wins, print ANDY; if Bob wins, print BOB.
To continue the example above, in the next move Andy will remove . Bob will then remove and win because there are no more integers to remove.
Complete the gamingArray function in the editor below.
gamingArray has the following parameter(s):
- string: either ANDY or BOB
The first line contains a single integer , the number of games.
Each of the next pairs of lines is as follows:
For of the maximum score:
Sample Input 0
5 2 6 3 4
Sample Output 0
Andy and Bob play the following two games:
Initially, the array looks like this:
In the first move, Bob removes and all the elements to its right, resulting in :
In the second move, Andy removes and all the elements to its right, resulting in :
At this point, the array is empty and Bob cannot make any more moves. This means Andy wins, so we print ANDY on a new line.
In the first move, Bob removes and all the elements to its right, resulting in . As there are no elements left in the array for Andy to make a move, Bob wins and we print BOB on a new line.
Sample Input 1
1 3 5 7 9
7 4 6 5 9
Sample Output 1
In the first test, they alternate choosing the rightmost element until the end. Bob, Andy, Bob, Andy, Bob.
In the second case, Bob takes , Andy takes .