title: Count Even Length Binary Sequences With Same Sum Of First And Second Half Bits 1
signature: func countEvenLengthBinarySequencesWithSameSumOfFirstAndSecondHalfBits1(n int) float64 {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual float64, expected float64) bool {
      return math.Abs(actual - expected) < 1e-09
  }
  
  func driver(n int, expected float64) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(25, 126410606437752.0)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(18, 9075135300.0)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(17, 2333606220.0)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(8, 12870.0)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(8, 12870.0)
      fmt.Printf("TEST-4...%s\n", result)
      
          
  }
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;
  }