title: Coin Game Winner Every Player Three Choices
signature: bool coinGameWinnerEveryPlayerThreeChoices(int x, int y, int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(bool actual, bool expected){
      return actual == expected;
  }
  
  string driver(int x, int y, int n, bool expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(x, y, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(6, 27, 51, false); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(32, 88, 69, true); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(99, 18, 48, false); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(22, 1, 74, true); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(26, 78, 95, false); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(67, 51, 27, true); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(69, 57, 91, true); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(39, 8, 9, false); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(7, 82, 41, true); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(91, 56, 7, true); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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 ];
  }