title: Circle Lattice Points
signature: function circleLatticePoints(r) {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value) {
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual, expected){
      return convertToString(actual)===convertToString(expected);
  }
  
  function driver(r, expected){
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(r),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(34, 12);
    console.log(`TEST-0...${result}`);
  
    result = driver(56, 4);
    console.log(`TEST-1...${result}`);
  
    result = driver(90, 12);
    console.log(`TEST-2...${result}`);
  
    result = driver(47, 4);
    console.log(`TEST-3...${result}`);
  
    result = driver(36, 4);
    console.log(`TEST-4...${result}`);
  
    result = driver(63, 4);
    console.log(`TEST-5...${result}`);
  
    result = driver(21, 4);
    console.log(`TEST-6...${result}`);
  
    result = driver(76, 4);
    console.log(`TEST-7...${result}`);
  
    result = driver(18, 4);
    console.log(`TEST-8...${result}`);
  
    result = driver(75, 20);
    console.log(`TEST-9...${result}`);
  
    process.exit(0);
  };
  
  if (require.main === module) {
    main();
  }
source_py: def circle_lattice_points(r):
      if (r <= 0):
          return 0
      result = 4
      for x in range(1, r):
          ySquare = ((r * r) - (x * x))
          y = int(math.sqrt(ySquare))
          if ((y * y) == ySquare):
              result += 4
      return result
source_cpp: int circle_lattice_points(int r) {
    if ( r <= 0 ) return 0;
    int result = 4;
    for ( int x = 1;
    x < r;
    x ++ ) {
      int ySquare = r * r - x * x;
      int y = sqrt ( ySquare );
      if ( y * y == ySquare ) result += 4;
    }
    return result;
  }