title: Integer Positive Value Positive Negative Value Array 1
signature: function integer_positive_value_positive_negative_value_array_1(arr, n)
source_py: def integer_positive_value_positive_negative_value_array_1(arr, n):
      neg = 0
      pos = 0
      sum = 0
      for i in range(0, n):
          sum += arr[i]
          if (arr[i] < 0):
              neg += 1
          else:
              pos += 1
      return (sum / abs((neg - pos)))
source_cpp: int integer_positive_value_positive_negative_value_array_1(vector<int> arr, int n) {
    int neg = 0, pos = 0;
    int sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      sum += arr [ i ];
      if ( arr [ i ] < 0 ) neg ++;
      else pos ++;
    }
    return ( sum / abs ( neg - pos ) );
  }
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 math.abs(actual - expected) < 1e-09
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, 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({49, 98}, 1, 49.0)
      print(string.format("TEST-0...%s",result))
  
      result = driver({82, 66, -68, 24, -10}, 2, 74.0)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, 8, 0.125)
      print(string.format("TEST-2...%s",result))
  
      result = driver({56, 3, 18, 5, 20, 56, 47, 29, 60, 98, 60, 40, 42, 2, 54, 56, 91, 8, 93, 14, 31, 27, 61, 49, 23, 12, 71}, 25, 41.72)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-94, -94, -92, -86, -50, -48, -6, 8, 28, 40, 44, 58, 62, 72, 94}, 12, -146.0)
      print(string.format("TEST-4...%s",result))
  
      result = driver({0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1}, 36, 0.5833333333333334)
      print(string.format("TEST-5...%s",result))
  
      result = driver({16, 56, 56}, 1, 16.0)
      print(string.format("TEST-6...%s",result))
  
      result = driver({74, -90, -92, 30, -18, 66, -66, 22}, 5, -96.0)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 7, 0.5714285714285714)
      print(string.format("TEST-8...%s",result))
  
      result = driver({21, 64, 82, 78, 30, 34, 35}, 5, 55.0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 49.0, "inputs": {"arr": [49, 98], "n": 1}}, {"idx": 1, "outputs": 74.0, "inputs": {"arr": [82, 66, -68, 24, -10], "n": 2}}, {"idx": 2, "outputs": 0.125, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], "n": 8}}, {"idx": 3, "outputs": 41.72, "inputs": {"arr": [56, 3, 18, 5, 20, 56, 47, 29, 60, 98, 60, 40, 42, 2, 54, 56, 91, 8, 93, 14, 31, 27, 61, 49, 23, 12, 71], "n": 25}}, {"idx": 4, "outputs": -146.0, "inputs": {"arr": [-94, -94, -92, -86, -50, -48, -6, 8, 28, 40, 44, 58, 62, 72, 94], "n": 12}}, {"idx": 5, "outputs": 0.5833333333333334, "inputs": {"arr": [0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1], "n": 36}}, {"idx": 6, "outputs": 16.0, "inputs": {"arr": [16, 56, 56], "n": 1}}, {"idx": 7, "outputs": -96.0, "inputs": {"arr": [74, -90, -92, 30, -18, 66, -66, 22], "n": 5}}, {"idx": 8, "outputs": 0.5714285714285714, "inputs": {"arr": [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 7}}, {"idx": 9, "outputs": 55.0, "inputs": {"arr": [21, 64, 82, 78, 30, 34, 35], "n": 5}}]
question_info.extension: lua
question_info.entry_fn_name: integer_positive_value_positive_negative_value_array_1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__