title: Coin Game Winner Every Player Three Choices
signature: coin_game_winner_every_player_three_choices <- function(x, y, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(x, y, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(x, y, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          6L, 27L, 51L, 
          FALSE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          32L, 88L, 69L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          99L, 18L, 48L, 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          22L, 1L, 74L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          26L, 78L, 95L, 
          FALSE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          67L, 51L, 27L, 
          TRUE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          69L, 57L, 91L, 
          TRUE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          39L, 8L, 9L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          7L, 82L, 41L, 
          TRUE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          91L, 56L, 7L, 
          TRUE
      )))
  
  }
  
  main()
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 ];
  }