title: Triangular Numbers
signature: bool triangularNumbers(int num) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(bool actual, bool expected){
      return actual == expected;
  }
  
  string driver(int num, bool expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(num), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(97, false); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(97, false); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(32, false); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(40, false); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(18, false); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(14, false); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(90, false); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(39, false); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(1, true); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(57, false); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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;
  }