title: Tiling With Dominoes
signature: function tiling_with_dominoes(n)
source_py: def tiling_with_dominoes(n):
      A = ([0] * (n + 1))
      B = ([0] * (n + 1))
      A[0] = 1
      A[1] = 0
      B[0] = 0
      B[1] = 1
      for i in range(2, (n + 1)):
          A[i] = (A[(i - 2)] + (2 * B[(i - 1)]))
          B[i] = (A[(i - 1)] + B[(i - 2)])
      return A[n]
source_cpp: int tiling_with_dominoes(int n) {
    int A [ n + 1 ], B [ n + 1 ];
    A [ 0 ] = 1, A [ 1 ] = 0, B [ 0 ] = 0, B [ 1 ] = 1;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      A [ i ] = A [ i - 2 ] + 2 * B [ i - 1 ];
      B [ i ] = A [ i - 1 ] + B [ i - 2 ];
    }
    return A [ n ];
  }
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(29, 0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(13, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(25, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(65, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(27, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(42, 808717138331)
      print(string.format("TEST-5...%s",result))
  
      result = driver(19, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(50, 156886956080403)
      print(string.format("TEST-7...%s",result))
  
      result = driver(59, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver(13, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"n": 29}}, {"idx": 1, "outputs": 0, "inputs": {"n": 13}}, {"idx": 2, "outputs": 0, "inputs": {"n": 25}}, {"idx": 3, "outputs": 0, "inputs": {"n": 65}}, {"idx": 4, "outputs": 0, "inputs": {"n": 27}}, {"idx": 5, "outputs": 808717138331, "inputs": {"n": 42}}, {"idx": 6, "outputs": 0, "inputs": {"n": 19}}, {"idx": 7, "outputs": 156886956080403, "inputs": {"n": 50}}, {"idx": 8, "outputs": 0, "inputs": {"n": 59}}, {"idx": 9, "outputs": 0, "inputs": {"n": 13}}]
question_info.extension: lua
question_info.entry_fn_name: tiling_with_dominoes
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__