title: Count Ways Build Street Given Constraints
signature: function count_ways_build_street_given_constraints(n)
source_py: def count_ways_build_street_given_constraints(n):
      dp = [([0] * (n + 1)) for i in range(2)]
      dp[0][1] = 1
      dp[1][1] = 2
      for i in range(2, (n + 1)):
          dp[0][i] = (dp[0][(i - 1)] + dp[1][(i - 1)])
          dp[1][i] = ((dp[0][(i - 1)] * 2) + dp[1][(i - 1)])
      return (dp[0][n] + dp[1][n])
source_cpp: long count_ways_build_street_given_constraints(int n) {
    long dp [ 2 ] [ n + 1 ];
    dp [ 0 ] [ 1 ] = 1;
    dp [ 1 ] [ 1 ] = 2;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + dp [ 1 ] [ i - 1 ];
      dp [ 1 ] [ i ] = dp [ 0 ] [ i - 1 ] * 2 + dp [ 1 ] [ i - 1 ];
    }
    return dp [ 0 ] [ n ] + dp [ 1 ] [ 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(20, 54608393)
      print(string.format("TEST-0...%s",result))
  
      result = driver(1, 3)
      print(string.format("TEST-1...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 54608393, "inputs": {"n": 20}}, {"idx": 1, "outputs": 3, "inputs": {"n": 1}}]
question_info.extension: lua
question_info.entry_fn_name: count_ways_build_street_given_constraints
question_info.test_case_ids: 0 1
question_info.commands: lua __FILENAME__