title: Triangular Numbers
signature: fun triangularNumbers(num: Int): Boolean {
source_py: def triangular_numbers(num):
      if (num < 0):
          return False
      (sum, n) = (0, 1)
      while (sum <= num):
          sum = (sum + n)
          if (sum == num):
              return True
          n += 1
      return False
source_cpp: bool triangular_numbers(int num) {
    if ( num < 0 ) return false;
    int sum = 0;
    for ( int n = 1;
    sum <= num;
    n ++ ) {
      sum = sum + n;
      if ( sum == num ) return true;
    }
    return false;
  }
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"num": 97}}, {"idx": 1, "outputs": false, "inputs": {"num": 97}}, {"idx": 2, "outputs": false, "inputs": {"num": 32}}, {"idx": 3, "outputs": false, "inputs": {"num": 40}}, {"idx": 4, "outputs": false, "inputs": {"num": 18}}, {"idx": 5, "outputs": false, "inputs": {"num": 14}}, {"idx": 6, "outputs": false, "inputs": {"num": 90}}, {"idx": 7, "outputs": false, "inputs": {"num": 39}}, {"idx": 8, "outputs": true, "inputs": {"num": 1}}, {"idx": 9, "outputs": false, "inputs": {"num": 57}}]
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:Boolean, expected:Boolean):Boolean{
    return actual.equals(expected)
  }
  fun driver(num: Int, expected:Boolean):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(num), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(97, false)
      println("TEST-0...${result}")
      
      result = driver(97, false)
      println("TEST-1...${result}")
      
      result = driver(32, false)
      println("TEST-2...${result}")
      
      result = driver(40, false)
      println("TEST-3...${result}")
      
      result = driver(18, false)
      println("TEST-4...${result}")
      
      result = driver(14, false)
      println("TEST-5...${result}")
      
      result = driver(90, false)
      println("TEST-6...${result}")
      
      result = driver(39, false)
      println("TEST-7...${result}")
      
      result = driver(1, true)
      println("TEST-8...${result}")
      
      result = driver(57, false)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: triangularNumbers
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