title: Count Even Length Binary Sequences With Same Sum Of First And Second Half Bits 1
signature: function count_even_length_binary_sequences_with_same_sum_of_first_and_second_half_bits_1(n)
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;
  }
question_info.entry_fn_name: count_even_length_binary_sequences_with_same_sum_of_first_and_second_half_bits_1
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return math.abs(actual - expected) < 1e-09
  end
  
  function driver(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(25, 126410606437752.0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(18, 9075135300.0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(17, 2333606220.0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(8, 12870.0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(8, 12870.0)
      print(string.format("TEST-4...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 126410606437752.0, "inputs": {"n": 25}}, {"idx": 1, "outputs": 9075135300.0, "inputs": {"n": 18}}, {"idx": 2, "outputs": 2333606220.0, "inputs": {"n": 17}}, {"idx": 3, "outputs": 12870.0, "inputs": {"n": 8}}, {"idx": 4, "outputs": 12870.0, "inputs": {"n": 8}}]