title: Square Pyramidal Number Sum Squares
signature: func squarePyramidalNumberSumSquares(s 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(s int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(s),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(1, 1)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(5, 2)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(14, 3)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(140, 7)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(204, 8)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(3, -1)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(506, 11)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(42, -1)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(4, -1)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(87, -1)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def square_pyramidal_number_sum_squares(s):
      _sum = 0
      n = 1
      while (_sum < s):
          _sum += (n * n)
          n += 1
      n -= 1
      if (_sum == s):
          return n
      return (- 1)
source_cpp: int square_pyramidal_number_sum_squares(int s) {
    int sum = 0;
    for ( int n = 1;
    sum < s;
    n ++ ) {
      sum += n * n;
      if ( sum == s ) return n;
    }
    return - 1;
  }