title: Coin Game Winner Every Player Three Choices
signature: function coin_game_winner_every_player_three_choices(x, y, n)
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 ];
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(x, y, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(x, y, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(6, 27, 51, false)
      print(string.format("TEST-0...%s",result))
  
      result = driver(32, 88, 69, true)
      print(string.format("TEST-1...%s",result))
  
      result = driver(99, 18, 48, false)
      print(string.format("TEST-2...%s",result))
  
      result = driver(22, 1, 74, true)
      print(string.format("TEST-3...%s",result))
  
      result = driver(26, 78, 95, false)
      print(string.format("TEST-4...%s",result))
  
      result = driver(67, 51, 27, true)
      print(string.format("TEST-5...%s",result))
  
      result = driver(69, 57, 91, true)
      print(string.format("TEST-6...%s",result))
  
      result = driver(39, 8, 9, false)
      print(string.format("TEST-7...%s",result))
  
      result = driver(7, 82, 41, true)
      print(string.format("TEST-8...%s",result))
  
      result = driver(91, 56, 7, true)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"x": 6, "y": 27, "n": 51}}, {"idx": 1, "outputs": true, "inputs": {"x": 32, "y": 88, "n": 69}}, {"idx": 2, "outputs": false, "inputs": {"x": 99, "y": 18, "n": 48}}, {"idx": 3, "outputs": true, "inputs": {"x": 22, "y": 1, "n": 74}}, {"idx": 4, "outputs": false, "inputs": {"x": 26, "y": 78, "n": 95}}, {"idx": 5, "outputs": true, "inputs": {"x": 67, "y": 51, "n": 27}}, {"idx": 6, "outputs": true, "inputs": {"x": 69, "y": 57, "n": 91}}, {"idx": 7, "outputs": false, "inputs": {"x": 39, "y": 8, "n": 9}}, {"idx": 8, "outputs": true, "inputs": {"x": 7, "y": 82, "n": 41}}, {"idx": 9, "outputs": true, "inputs": {"x": 91, "y": 56, "n": 7}}]
question_info.extension: lua
question_info.entry_fn_name: coin_game_winner_every_player_three_choices
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__