title: Count Numbers Can Constructed Using Two Numbers
signature: function count_numbers_can_constructed_using_two_numbers(n, x, y)
source_py: def count_numbers_can_constructed_using_two_numbers(n, x, y):
      arr = [False for i in range((n + 2))]
      if (x <= n):
          arr[x] = True
      if (y <= n):
          arr[y] = True
      result = 0
      for i in range(min(x, y), (n + 1)):
          if arr[i]:
              if ((i + x) <= n):
                  arr[(i + x)] = True
              if ((i + y) <= n):
                  arr[(i + y)] = True
              result = (result + 1)
      return result
source_cpp: int count_numbers_can_constructed_using_two_numbers(int n, int x, int y) {
    vector < bool > arr ( n + 1, false );
    if ( x <= n ) arr [ x ] = true;
    if ( y <= n ) arr [ y ] = true;
    int result = 0;
    for ( int i = min ( x, y );
    i <= n;
    i ++ ) {
      if ( arr [ i ] ) {
        if ( i + x <= n ) arr [ i + x ] = true;
        if ( i + y <= n ) arr [ i + y ] = true;
        result ++;
      }
    }
    return result;
  }
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(n, x, y, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, x, y) 
      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(23, 16, 16, 1)
      print(string.format("TEST-0...%s",result))
  
      result = driver(56, 95, 6, 9)
      print(string.format("TEST-1...%s",result))
  
      result = driver(30, 63, 1, 30)
      print(string.format("TEST-2...%s",result))
  
      result = driver(51, 89, 46, 1)
      print(string.format("TEST-3...%s",result))
  
      result = driver(21, 99, 38, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(69, 63, 50, 2)
      print(string.format("TEST-5...%s",result))
  
      result = driver(12, 69, 73, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(44, 52, 9, 4)
      print(string.format("TEST-7...%s",result))
  
      result = driver(99, 65, 10, 13)
      print(string.format("TEST-8...%s",result))
  
      result = driver(46, 58, 37, 1)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"n": 23, "x": 16, "y": 16}}, {"idx": 1, "outputs": 9, "inputs": {"n": 56, "x": 95, "y": 6}}, {"idx": 2, "outputs": 30, "inputs": {"n": 30, "x": 63, "y": 1}}, {"idx": 3, "outputs": 1, "inputs": {"n": 51, "x": 89, "y": 46}}, {"idx": 4, "outputs": 0, "inputs": {"n": 21, "x": 99, "y": 38}}, {"idx": 5, "outputs": 2, "inputs": {"n": 69, "x": 63, "y": 50}}, {"idx": 6, "outputs": 0, "inputs": {"n": 12, "x": 69, "y": 73}}, {"idx": 7, "outputs": 4, "inputs": {"n": 44, "x": 52, "y": 9}}, {"idx": 8, "outputs": 13, "inputs": {"n": 99, "x": 65, "y": 10}}, {"idx": 9, "outputs": 1, "inputs": {"n": 46, "x": 58, "y": 37}}]
question_info.extension: lua
question_info.entry_fn_name: count_numbers_can_constructed_using_two_numbers
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__