title: Square Pyramidal Number Sum Squares
signature: function squarePyramidalNumberSumSquares($s) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($s, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($s), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        1, 
        1));
      
      printf("TEST-1...%s\n",driver(
        5, 
        2));
      
      printf("TEST-2...%s\n",driver(
        14, 
        3));
      
      printf("TEST-3...%s\n",driver(
        140, 
        7));
      
      printf("TEST-4...%s\n",driver(
        204, 
        8));
      
      printf("TEST-5...%s\n",driver(
        3, 
        -1));
      
      printf("TEST-6...%s\n",driver(
        506, 
        11));
      
      printf("TEST-7...%s\n",driver(
        42, 
        -1));
      
      printf("TEST-8...%s\n",driver(
        4, 
        -1));
      
      printf("TEST-9...%s\n",driver(
        87, 
        -1));
      
  }
  
  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;
  }