title: Find Sum Even Index Binomial Coefficients
signature: function find_sum_even_index_binomial_coefficients(n)
source_py: def find_sum_even_index_binomial_coefficients(n):
      C = [[0 for x in range((n + 1))] for y in range((n + 1))]
      for i in range(0, (n + 1)):
          for j in range(0, min(i, (n + 1))):
              if ((j == 0) or (j == i)):
                  C[i][j] = 1
              else:
                  C[i][j] = (C[(i - 1)][(j - 1)] + C[(i - 1)][j])
      sum = 0
      for i in range(0, (n + 1)):
          if ((n % 2) == 0):
              sum = (sum + C[n][i])
      return sum
source_cpp: int find_sum_even_index_binomial_coefficients(int n) {
    int C [ n + 1 ] [ n + 1 ];
    int i, j;
    for ( i = 0;
    i <= n;
    i ++ ) {
      for ( j = 0;
      j <= min ( i, n );
      j ++ ) {
        if ( j == 0 || j == i ) C [ i ] [ j ] = 1;
        else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ];
      }
    }
    int sum = 0;
    for ( int i = 0;
    i <= n;
    i += 2 ) sum += C [ n ] [ i ];
    return sum;
  }
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 isCorrect(actual,expected)
  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(18, 131072)
      print(string.format("TEST-0...%s",result))
  
      result = driver(54, 9007199254740992)
      print(string.format("TEST-1...%s",result))
  
      result = driver(67, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(17, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(47, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(99, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(26, 33554432)
      print(string.format("TEST-6...%s",result))
  
      result = driver(93, 0)
      print(string.format("TEST-7...%s",result))
  
      result = driver(57, 0)
      print(string.format("TEST-8...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 131072, "inputs": {"n": 18}}, {"idx": 1, "outputs": 9007199254740992, "inputs": {"n": 54}}, {"idx": 2, "outputs": 0, "inputs": {"n": 67}}, {"idx": 3, "outputs": 0, "inputs": {"n": 17}}, {"idx": 4, "outputs": 0, "inputs": {"n": 47}}, {"idx": 5, "outputs": 0, "inputs": {"n": 99}}, {"idx": 6, "outputs": 33554432, "inputs": {"n": 26}}, {"idx": 7, "outputs": 0, "inputs": {"n": 93}}, {"idx": 8, "outputs": 0, "inputs": {"n": 57}}]
question_info.extension: lua
question_info.entry_fn_name: find_sum_even_index_binomial_coefficients
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8
question_info.commands: lua __FILENAME__