title: Probability Three Randomly Chosen Numbers Ap
signature: function probability_three_randomly_chosen_numbers_ap(n)
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(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(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(46, 0.0163062743707905)
      print(string.format("TEST-0...%s",result))
  
      result = driver(5, 0.15151515151515152)
      print(string.format("TEST-1...%s",result))
  
      result = driver(44, 0.017047655947307245)
      print(string.format("TEST-2...%s",result))
  
      result = driver(15, 0.05005561735261402)
      print(string.format("TEST-3...%s",result))
  
      result = driver(72, 0.010417169037858692)
      print(string.format("TEST-4...%s",result))
  
      result = driver(2, 0.4)
      print(string.format("TEST-5...%s",result))
  
      result = driver(86, 0.008721225027887637)
      print(string.format("TEST-6...%s",result))
  
      result = driver(17, 0.04415584415584416)
      print(string.format("TEST-7...%s",result))
  
      result = driver(30, 0.025006946373992776)
      print(string.format("TEST-8...%s",result))
  
      result = driver(42, 0.01785967399007796)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def probability_three_randomly_chosen_numbers_ap(n):
      return ((3.0 * n) / ((4.0 * (n * n)) - 1))
source_cpp: double probability_three_randomly_chosen_numbers_ap(int n) {
    return ( 3.0 * n ) / ( 4.0 * ( n * n ) - 1 );
  }