title: Count Distinct Non Negative Pairs X Y Satisfy Inequality Xx Yy N 2 1
signature: def countDistinctNonNegativePairsXYSatisfyInequalityXxYyN21(n: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Int , expected: Int): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(n: Int, expected: Int): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        72, 
        64    
      )}")   
  
  
      println(s"TEST-1...${driver(
        75, 
        69    
      )}")   
  
  
      println(s"TEST-2...${driver(
        92, 
        83    
      )}")   
  
  
      println(s"TEST-3...${driver(
        30, 
        30    
      )}")   
  
  
      println(s"TEST-4...${driver(
        45, 
        41    
      )}")   
  
  
      println(s"TEST-5...${driver(
        40, 
        37    
      )}")   
  
  
      println(s"TEST-6...${driver(
        81, 
        71    
      )}")   
  
  
      println(s"TEST-7...${driver(
        17, 
        17    
      )}")   
  
  
      println(s"TEST-8...${driver(
        81, 
        71    
      )}")   
  
  
      println(s"TEST-9...${driver(
        99, 
        86    
      )}")   
  
  }
  
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;
  }