title: Pair With Given Product Set 1 Find If Any Pair Exists
signature: function pair_with_given_product_set_1_find_if_any_pair_exists(arr, n, x)
source_py: def pair_with_given_product_set_1_find_if_any_pair_exists(arr, n, x):
      for i in arr:
          for j in arr:
              if ((i * j) == x):
                  return True
      return False
source_cpp: bool pair_with_given_product_set_1_find_if_any_pair_exists(vector<int> arr, int n, int x) {
    for ( int i = 0;
    i < n - 1;
    i ++ ) for ( int j = i + 1;
    i < n;
    i ++ ) if ( arr [ i ] * arr [ j ] == x ) return true;
    return false;
  }
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(arr, n, x, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n, x) 
      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({10, 20, 9, 40}, 4, 400, true)
      print(string.format("TEST-0...%s",result))
  
      result = driver({1, -10, 20, 9, -40}, 5, 400, true)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 1, 1, 1, 1}, 7, 8, false)
      print(string.format("TEST-2...%s",result))
  
      result = driver({4, 10, 20, 9, -40}, 5, -400, true)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-90, -86, -76, -72, -70, -62, -56, -50, -18, -12, -10, 4, 16, 26, 42, 48, 52, 54, 54, 70, 84, 86, 88, 98}, 23, 23, false)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1}, 0, 0, false)
      print(string.format("TEST-5...%s",result))
  
      result = driver({4, 7, 14, 14, 16, 18, 19, 20, 22, 24, 29, 38, 38, 38, 40, 40, 46, 46, 47, 51, 51, 52, 55, 56, 56, 62, 62, 62, 78, 79, 81, 84, 86, 88, 89, 89, 89}, 23, 32, false)
      print(string.format("TEST-6...%s",result))
  
      result = driver({72, 80, -82, 24, -98, 90, -32, -56, -22, 8, -12, 8, -78, 60, -62, 50, 12, -60, 10, -54, 74, 98, 26, 56, 24}, 21, 19, false)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 22, 18, false)
      print(string.format("TEST-8...%s",result))
  
      result = driver({93, 40, 48, 99, 95, 59, 43, 58, 79, 70, 28}, 9, 5, false)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"arr": [10, 20, 9, 40], "n": 4, "x": 400}}, {"idx": 1, "outputs": true, "inputs": {"arr": [1, -10, 20, 9, -40], "n": 5, "x": 400}}, {"idx": 2, "outputs": false, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1, 1], "n": 7, "x": 8}}, {"idx": 3, "outputs": true, "inputs": {"arr": [4, 10, 20, 9, -40], "n": 5, "x": -400}}, {"idx": 4, "outputs": false, "inputs": {"arr": [-90, -86, -76, -72, -70, -62, -56, -50, -18, -12, -10, 4, 16, 26, 42, 48, 52, 54, 54, 70, 84, 86, 88, 98], "n": 23, "x": 23}}, {"idx": 5, "outputs": false, "inputs": {"arr": [1], "n": 0, "x": 0}}, {"idx": 6, "outputs": false, "inputs": {"arr": [4, 7, 14, 14, 16, 18, 19, 20, 22, 24, 29, 38, 38, 38, 40, 40, 46, 46, 47, 51, 51, 52, 55, 56, 56, 62, 62, 62, 78, 79, 81, 84, 86, 88, 89, 89, 89], "n": 23, "x": 32}}, {"idx": 7, "outputs": false, "inputs": {"arr": [72, 80, -82, 24, -98, 90, -32, -56, -22, 8, -12, 8, -78, 60, -62, 50, 12, -60, 10, -54, 74, 98, 26, 56, 24], "n": 21, "x": 19}}, {"idx": 8, "outputs": false, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 22, "x": 18}}, {"idx": 9, "outputs": false, "inputs": {"arr": [93, 40, 48, 99, 95, 59, 43, 58, 79, 70, 28], "n": 9, "x": 5}}]
question_info.extension: lua
question_info.entry_fn_name: pair_with_given_product_set_1_find_if_any_pair_exists
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__