title: Square Pyramidal Number Sum Squares
signature: function squarePyramidalNumberSumSquares(s: number): number {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(s: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(s),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(1, 1);
    console.log(`TEST-0...${result}`);
  
    result = driver(5, 2);
    console.log(`TEST-1...${result}`);
  
    result = driver(14, 3);
    console.log(`TEST-2...${result}`);
  
    result = driver(140, 7);
    console.log(`TEST-3...${result}`);
  
    result = driver(204, 8);
    console.log(`TEST-4...${result}`);
  
    result = driver(3, -1);
    console.log(`TEST-5...${result}`);
  
    result = driver(506, 11);
    console.log(`TEST-6...${result}`);
  
    result = driver(42, -1);
    console.log(`TEST-7...${result}`);
  
    result = driver(4, -1);
    console.log(`TEST-8...${result}`);
  
    result = driver(87, -1);
    console.log(`TEST-9...${result}`);
  
  };
  
  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;
  }