title: Circle Lattice Points
signature: circleLatticePoints(r) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(r, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(r), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          34, 
          12)
      }");
  
      print("TEST-1...${driver(
          56, 
          4)
      }");
  
      print("TEST-2...${driver(
          90, 
          12)
      }");
  
      print("TEST-3...${driver(
          47, 
          4)
      }");
  
      print("TEST-4...${driver(
          36, 
          4)
      }");
  
      print("TEST-5...${driver(
          63, 
          4)
      }");
  
      print("TEST-6...${driver(
          21, 
          4)
      }");
  
      print("TEST-7...${driver(
          76, 
          4)
      }");
  
      print("TEST-8...${driver(
          18, 
          4)
      }");
  
      print("TEST-9...${driver(
          75, 
          20)
      }");
  
      return 0;
  }
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;
  }