title: Square Pyramidal Number Sum Squares
signature: fun squarePyramidalNumberSumSquares(s: Int): Int {
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;
  }
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"s": 1}}, {"idx": 1, "outputs": 2, "inputs": {"s": 5}}, {"idx": 2, "outputs": 3, "inputs": {"s": 14}}, {"idx": 3, "outputs": 7, "inputs": {"s": 140}}, {"idx": 4, "outputs": 8, "inputs": {"s": 204}}, {"idx": 5, "outputs": -1, "inputs": {"s": 3}}, {"idx": 6, "outputs": 11, "inputs": {"s": 506}}, {"idx": 7, "outputs": -1, "inputs": {"s": 42}}, {"idx": 8, "outputs": -1, "inputs": {"s": 4}}, {"idx": 9, "outputs": -1, "inputs": {"s": 87}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(s: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(s), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(1, 1)
      println("TEST-0...${result}")
      
      result = driver(5, 2)
      println("TEST-1...${result}")
      
      result = driver(14, 3)
      println("TEST-2...${result}")
      
      result = driver(140, 7)
      println("TEST-3...${result}")
      
      result = driver(204, 8)
      println("TEST-4...${result}")
      
      result = driver(3, -1)
      println("TEST-5...${result}")
      
      result = driver(506, 11)
      println("TEST-6...${result}")
      
      result = driver(42, -1)
      println("TEST-7...${result}")
      
      result = driver(4, -1)
      println("TEST-8...${result}")
      
      result = driver(87, -1)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: squarePyramidalNumberSumSquares
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn