title: Sum Of All Elements Up To Nth Row In A Pascals Triangle
signature: function sum_of_all_elements_up_to_nth_row_in_a_pascals_triangle(n)
source_py: def sum_of_all_elements_up_to_nth_row_in_a_pascals_triangle(n):
      sum = 0
      for row in range(n):
          sum = (sum + (1 << row))
      return sum
source_cpp: long long int sum_of_all_elements_up_to_nth_row_in_a_pascals_triangle(int n) {
    long long int sum = 0;
    for ( int row = 0;
    row < n;
    row ++ ) {
      sum = sum + ( 1 << row );
    }
    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(21, 2097151)
      print(string.format("TEST-0...%s",result))
  
      result = driver(4, 15)
      print(string.format("TEST-1...%s",result))
  
      result = driver(31, 2147483647)
      print(string.format("TEST-2...%s",result))
  
      result = driver(38, 274877906943)
      print(string.format("TEST-3...%s",result))
  
      result = driver(36, 68719476735)
      print(string.format("TEST-4...%s",result))
  
      result = driver(32, 4294967295)
      print(string.format("TEST-5...%s",result))
  
      result = driver(23, 8388607)
      print(string.format("TEST-6...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 2097151, "inputs": {"n": 21}}, {"idx": 1, "outputs": 15, "inputs": {"n": 4}}, {"idx": 2, "outputs": 2147483647, "inputs": {"n": 31}}, {"idx": 3, "outputs": 274877906943, "inputs": {"n": 38}}, {"idx": 4, "outputs": 68719476735, "inputs": {"n": 36}}, {"idx": 5, "outputs": 4294967295, "inputs": {"n": 32}}, {"idx": 6, "outputs": 8388607, "inputs": {"n": 23}}]
question_info.extension: lua
question_info.entry_fn_name: sum_of_all_elements_up_to_nth_row_in_a_pascals_triangle
question_info.test_case_ids: 0 1 2 3 4 5 6
question_info.commands: lua __FILENAME__