title: Circle Lattice Points
signature: circle_lattice_points <- function(r) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(r, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(r), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          34L, 
          12L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          56L, 
          4L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          90L, 
          12L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          47L, 
          4L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          36L, 
          4L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          63L, 
          4L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          21L, 
          4L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          76L, 
          4L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          18L, 
          4L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          75L, 
          20L
      )))
  
  }
  
  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;
  }