title: Coin Game Winner Every Player Three Choices
signature: class Solution {
  
      public Boolean coinGameWinnerEveryPlayerThreeChoices(Integer x, Integer y, Integer n) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer x, Integer y, Integer n, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(x, y, n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(6, 27, 51, false);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(32, 88, 69, true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(99, 18, 48, false);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(22, 1, 74, true);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(26, 78, 95, false);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(67, 51, 27, true);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(69, 57, 91, true);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(39, 8, 9, false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(7, 82, 41, true);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(91, 56, 7, true);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer x, Integer y, Integer n, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(x, y, n),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def coin_game_winner_every_player_three_choices(x, y, n):
      dp = [0 for i in range((n + 1))]
      dp[0] = False
      dp[1] = True
      for i in range(2, (n + 1)):
          if (((i - 1) >= 0) and (not dp[(i - 1)])):
              dp[i] = True
          elif (((i - x) >= 0) and (not dp[(i - x)])):
              dp[i] = True
          elif (((i - y) >= 0) and (not dp[(i - y)])):
              dp[i] = True
          else:
              dp[i] = False
      return dp[n]
source_cpp: bool coin_game_winner_every_player_three_choices(int x, int y, int n) {
    int dp [ n + 1 ];
    dp [ 0 ] = false;
    dp [ 1 ] = true;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      if ( i - 1 >= 0 and ! dp [ i - 1 ] ) dp [ i ] = true;
      else if ( i - x >= 0 and ! dp [ i - x ] ) dp [ i ] = true;
      else if ( i - y >= 0 and ! dp [ i - y ] ) dp [ i ] = true;
      else dp [ i ] = false;
    }
    return dp [ n ];
  }