title: Square Pyramidal Number Sum Squares
signature: square_pyramidal_number_sum_squares <- function(s) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(s, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(s), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          1L, 
          1L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          5L, 
          2L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          14L, 
          3L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          140L, 
          7L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          204L, 
          8L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          3L, 
          -1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          506L, 
          11L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          42L, 
          -1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          4L, 
          -1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          87L, 
          -1L
      )))
  
  }
  
  main()
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;
  }