title: Count Even Length Binary Sequences With Same Sum Of First And Second Half Bits 1
signature: def countEvenLengthBinarySequencesWithSameSumOfFirstAndSecondHalfBits1(n: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Double , expected: Double): Boolean = {
      (actual - expected).abs < 1e-09
  }
  
  def driver(n: Int, expected: Double): 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(
        25, 
        126410606437752.0    
      )}")   
  
  
      println(s"TEST-1...${driver(
        18, 
        9075135300.0    
      )}")   
  
  
      println(s"TEST-2...${driver(
        17, 
        2333606220.0    
      )}")   
  
  
      println(s"TEST-3...${driver(
        8, 
        12870.0    
      )}")   
  
  
      println(s"TEST-4...${driver(
        8, 
        12870.0    
      )}")   
  
  }
  
source_py: def count_even_length_binary_sequences_with_same_sum_of_first_and_second_half_bits_1(n):
      nCr = 1
      res = 1
      for r in range(1, (n + 1)):
          nCr = ((nCr * ((n + 1) - r)) / r)
          res += (nCr * nCr)
      return res
source_cpp: int count_even_length_binary_sequences_with_same_sum_of_first_and_second_half_bits_1(int n) {
    int nCr = 1, res = 1;
    for ( int r = 1;
    r <= n;
    r ++ ) {
      nCr = ( nCr * ( n + 1 - r ) ) / r;
      res += nCr * nCr;
    }
    return res;
  }