Find the Winning Player in Coin Game - Problem
You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively.
Alice and Bob are playing a game. Each turn, starting with Alice, the player must pick up coins with a total value of exactly 115. If the player is unable to do so, they lose the game.
Return the name of the player who wins the game if both players play optimally.
Input & Output
Example 1 — Basic Case
$
Input:
x = 2, y = 8
›
Output:
Bob
💡 Note:
Maximum turns = min(2, 8÷4) = min(2, 2) = 2. Since 2 is even, Bob wins.
Example 2 — Alice Wins
$
Input:
x = 4, y = 11
›
Output:
Bob
💡 Note:
Maximum turns = min(4, 11÷4) = min(4, 2) = 2. Since 2 is even, Bob wins.
Example 3 — Insufficient Coins
$
Input:
x = 1, y = 3
›
Output:
Bob
💡 Note:
Need 1×75 + 4×10 = 115, but only have 3 ten-coins (need 4). Alice can't make first move, so Bob wins.
Constraints
- 1 ≤ x, y ≤ 100
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code