title: Triangular Numbers 1
signature: bool triangularNumbers1(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(1, true); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(3, true); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(6, true); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(10, true); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(55, true); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(48, false); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(63, false); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(72, false); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(16, false); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(85, false); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def triangular_numbers_1(num):
      if (num < 0):
          return False
      c = ((- 2) * num)
      (b, a) = (1, 1)
      d = ((b * b) - ((4 * a) * c))
      if (d < 0):
          return False
      root1 = (((- b) + math.sqrt(d)) / (2 * a))
      root2 = (((- b) - math.sqrt(d)) / (2 * a))
      if ((root1 > 0) and (math.floor(root1) == root1)):
          return True
      if ((root2 > 0) and (math.floor(root2) == root2)):
          return True
      return False
source_cpp: bool triangular_numbers_1(int num) {
    if ( num < 0 ) return false;
    int c = ( - 2 * num );
    int b = 1, a = 1;
    int d = ( b * b ) - ( 4 * a * c );
    if ( d < 0 ) return false;
    float root1 = ( - b + sqrt ( d ) ) / ( 2 * a );
    float root2 = ( - b - sqrt ( d ) ) / ( 2 * a );
    if ( root1 > 0 && floor ( root1 ) == root1 ) return true;
    if ( root2 > 0 && floor ( root2 ) == root2 ) return true;
    return false;
  }