title: Circle Lattice Points
signature: func circleLatticePoints(r int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(r int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(r),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(34, 12)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(56, 4)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(90, 12)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(47, 4)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(36, 4)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(63, 4)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(21, 4)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(76, 4)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(18, 4)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(75, 20)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
  }