Given the count of total stones in a game. Two-player βAleβ and βBobβ are playing the game. Your task is to find who will win the game if both the players are playing optimally.
Rules of the game.
1. In a single turn, a player can choose a single stone or βevenβ number of stones.
2. They will play alternatively, which means in the first chance βAleβ will collect the stones, in second-chance βBobβ will collect the stones. And always βAleβ will start the game.
3. If any player is not able to take any stones then another player will win the game.
The first line of input contains an integer βTβ denoting the number of test cases.
The first line of each test case contains a single integer, which denotes the total number of stones in the game.
Output Format:
For each test case, return a string βAleβ or βBobβ according to your answer.
Note:
1. Do not print anything, just return βAleβ if βAleβ will win the game else return βBobβ.
1 <= T <= 10^5
1 <= number of stones <= 10^9
Where βTβ is the total number of test cases.
Time limit: 1 second
2
2
3
Ale
Bob
Test Case 1:
Given the number of stones is β2β.
Then first player βAleβ can choose both the stones because 2 is an even number.
So βAleβ will the game.
Return βAleβ.
Test Case 2:
Given the number of stones is β3β.
In the first turn βAleβ can choose β1β stone or β2β store, but not β3β stone because β3β is neither β1β or even number.
If βAleβ chooses β1β in the first turn. Then in the second turn, βBobβ will collect the remaining β2β stone, so βBobβ will win.
If βAleβ chooses β2β stones in the first turn. Then in the second turn, βBobβ will collect the remaining β1β stone, again βBobβ will win the game.
So in both cases βBobβ is winning the game. Hence Return βBobβ.
2
4
6
Ale
Ale
Find cases when βAleβ can lose the game.
0(1), we are taking a constant time.
O(1), we are using constant space.