title: Count Distinct Non Negative Pairs X Y Satisfy Inequality Xx Yy N 2 1
signature: function count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(n)
source_py: def count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(n):
      x = 0
      res = 0
      yCount = 0
      while ((yCount * yCount) < n):
          yCount = (yCount + 1)
      while (yCount != 0):
          res = (res + yCount)
          x = (x + 1)
          while ((yCount != 0) and (((x * x) + ((yCount - 1) * (yCount - 1))) >= n)):
              yCount = (yCount - 1)
      return res
source_cpp: int count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(int n) {
    int x = 0, yCount, res = 0;
    for ( yCount = 0;
    yCount * yCount < n;
    yCount ++ );
    while ( yCount != 0 ) {
      res += yCount;
      x ++;
      while ( yCount != 0 && ( x * x + ( yCount - 1 ) * ( yCount - 1 ) >= n ) ) yCount --;
    }
    return res;
  }
question_info.entry_fn_name: count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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, 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(72, 64)
      print(string.format("TEST-0...%s",result))
  
      result = driver(75, 69)
      print(string.format("TEST-1...%s",result))
  
      result = driver(92, 83)
      print(string.format("TEST-2...%s",result))
  
      result = driver(30, 30)
      print(string.format("TEST-3...%s",result))
  
      result = driver(45, 41)
      print(string.format("TEST-4...%s",result))
  
      result = driver(40, 37)
      print(string.format("TEST-5...%s",result))
  
      result = driver(81, 71)
      print(string.format("TEST-6...%s",result))
  
      result = driver(17, 17)
      print(string.format("TEST-7...%s",result))
  
      result = driver(81, 71)
      print(string.format("TEST-8...%s",result))
  
      result = driver(99, 86)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 64, "inputs": {"n": 72}}, {"idx": 1, "outputs": 69, "inputs": {"n": 75}}, {"idx": 2, "outputs": 83, "inputs": {"n": 92}}, {"idx": 3, "outputs": 30, "inputs": {"n": 30}}, {"idx": 4, "outputs": 41, "inputs": {"n": 45}}, {"idx": 5, "outputs": 37, "inputs": {"n": 40}}, {"idx": 6, "outputs": 71, "inputs": {"n": 81}}, {"idx": 7, "outputs": 17, "inputs": {"n": 17}}, {"idx": 8, "outputs": 71, "inputs": {"n": 81}}, {"idx": 9, "outputs": 86, "inputs": {"n": 99}}]