title: Check Number Is Perfect Square Using Additionsubtraction
signature: def checkNumberIsPerfectSquareUsingAdditionsubtraction(n: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Boolean , expected: Boolean): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(n: Int, expected: Boolean): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        1, 
        true    
      )}")   
  
  
      println(s"TEST-1...${driver(
        4, 
        true    
      )}")   
  
  
      println(s"TEST-2...${driver(
        9, 
        true    
      )}")   
  
  
      println(s"TEST-3...${driver(
        25, 
        true    
      )}")   
  
  
      println(s"TEST-4...${driver(
        36, 
        true    
      )}")   
  
  
      println(s"TEST-5...${driver(
        3, 
        false    
      )}")   
  
  
      println(s"TEST-6...${driver(
        121, 
        true    
      )}")   
  
  
      println(s"TEST-7...${driver(
        14, 
        false    
      )}")   
  
  
      println(s"TEST-8...${driver(
        17, 
        false    
      )}")   
  
  
      println(s"TEST-9...${driver(
        80, 
        false    
      )}")   
  
  }
  
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;
  }