title: Check Number Is Perfect Square Using Additionsubtraction
signature: check_number_is_perfect_square_using_additionsubtraction <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          1L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          4L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          9L, 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          25L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          36L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          3L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          121L, 
          TRUE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          14L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          17L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          80L, 
          FALSE
      )))
  
  }
  
  main()
source_py: def check_number_is_perfect_square_using_additionsubtraction(n):
      i = 1
      the_sum = 0
      while (the_sum < n):
          the_sum += i
          if (the_sum == n):
              return True
          i += 2
      return False
source_cpp: bool check_number_is_perfect_square_using_additionsubtraction(int n) {
    for ( int sum = 0, i = 1;
    sum < n;
    i += 2 ) {
      sum += i;
      if ( sum == n ) return true;
    }
    return false;
  }