title: Circle Lattice Points
signature: function circleLatticePoints($r) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($r, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($r), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        34, 
        12));
      
      printf("TEST-1...%s\n",driver(
        56, 
        4));
      
      printf("TEST-2...%s\n",driver(
        90, 
        12));
      
      printf("TEST-3...%s\n",driver(
        47, 
        4));
      
      printf("TEST-4...%s\n",driver(
        36, 
        4));
      
      printf("TEST-5...%s\n",driver(
        63, 
        4));
      
      printf("TEST-6...%s\n",driver(
        21, 
        4));
      
      printf("TEST-7...%s\n",driver(
        76, 
        4));
      
      printf("TEST-8...%s\n",driver(
        18, 
        4));
      
      printf("TEST-9...%s\n",driver(
        75, 
        20));
      
  }
  
  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;
  }