title: Triangular Numbers
signature: function triangularNumbers(num: number): 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.entry_cls_name: Solution
question_info.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: boolean, expected: boolean): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(num: number, expected:boolean): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(num),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(97, false);
    console.log(`TEST-0...${result}`);
  
    result = driver(97, false);
    console.log(`TEST-1...${result}`);
  
    result = driver(32, false);
    console.log(`TEST-2...${result}`);
  
    result = driver(40, false);
    console.log(`TEST-3...${result}`);
  
    result = driver(18, false);
    console.log(`TEST-4...${result}`);
  
    result = driver(14, false);
    console.log(`TEST-5...${result}`);
  
    result = driver(90, false);
    console.log(`TEST-6...${result}`);
  
    result = driver(39, false);
    console.log(`TEST-7...${result}`);
  
    result = driver(1, true);
    console.log(`TEST-8...${result}`);
  
    result = driver(57, false);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: triangularNumbers
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js