Game of Stones Problem Statement

Two players, 'Ale' and 'Bob', are playing a game with a pile of stones. Your task is to determine the winner if both play optimally.

Rules of the Game:

1. On each turn, a player can choose to take either one stone or any even number of stones.

2. Players play alternately, with 'Ale' always going first, followed by 'Bob'.

3. If a player cannot take any stones, the other player wins the game.

Input:

The first line contains an integer ‘T’, the number of test cases.
Each test case contains a single integer, representing the total number of stones in the game.

Output:

For each test case, return a string 'Ale' or 'Bob' indicating the winner.

Example:

Input:
T = 2
7
10
Output:
'Ale'
'Bob'

Constraints:

  • 1 <= T <= 105
  • 1 <= number of stones <= 109

Note:

  • Do not print anything; return 'Ale' if 'Ale' will win the game, otherwise return 'Bob'.
AnswerBot
4d

Determine the winner of a game where two players take stones alternately, with specific rules.

  • Implement a recursive function to simulate the game, considering the rules provided.

  • Check if the current p...read more

Help your peers!
Add answer anonymously...
Samsung Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter