title: Number N Digit Stepping Numbers
signature: function number_n_digit_stepping_numbers(n)
source_py: def number_n_digit_stepping_numbers(n):
      dp = [[0 for x in range(10)] for y in range((n + 1))]
      if (n == 1):
          return 10
      for j in range(10):
          dp[1][j] = 1
      for i in range(2, (n + 1)):
          for j in range(10):
              if (j == 0):
                  dp[i][j] = dp[(i - 1)][(j + 1)]
              elif (j == 9):
                  dp[i][j] = dp[(i - 1)][(j - 1)]
              else:
                  dp[i][j] = (dp[(i - 1)][(j - 1)] + dp[(i - 1)][(j + 1)])
      sum = 0
      for j in range(1, 10):
          sum = (sum + dp[n][j])
      return sum
source_cpp: long long number_n_digit_stepping_numbers(int n) {
    int dp [ n + 1 ] [ 10 ];
    if ( n == 1 ) return 10;
    for ( int j = 0;
    j <= 9;
    j ++ ) dp [ 1 ] [ j ] = 1;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      for ( int j = 0;
      j <= 9;
      j ++ ) {
        if ( j == 0 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j + 1 ];
        else if ( j == 9 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ];
        else dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] + dp [ i - 1 ] [ j + 1 ];
      }
    }
    long long sum = 0;
    for ( int j = 1;
    j <= 9;
    j ++ ) sum += dp [ n ] [ j ];
    return sum;
  }
question_info.entry_fn_name: number_n_digit_stepping_numbers
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6']
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, 547810)
      print(string.format("TEST-0...%s",result))
  
      result = driver(26, 100719775)
      print(string.format("TEST-1...%s",result))
  
      result = driver(41, 1774846161206)
      print(string.format("TEST-2...%s",result))
  
      result = driver(20, 2017126)
      print(string.format("TEST-3...%s",result))
  
      result = driver(25, 52479500)
      print(string.format("TEST-4...%s",result))
  
      result = driver(52, 2306507126768895)
      print(string.format("TEST-5...%s",result))
  
      result = driver(13, 21053)
      print(string.format("TEST-6...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 547810, "inputs": {"n": 18}}, {"idx": 1, "outputs": 100719775, "inputs": {"n": 26}}, {"idx": 2, "outputs": 1774846161206, "inputs": {"n": 41}}, {"idx": 3, "outputs": 2017126, "inputs": {"n": 20}}, {"idx": 4, "outputs": 52479500, "inputs": {"n": 25}}, {"idx": 5, "outputs": 2306507126768895, "inputs": {"n": 52}}, {"idx": 6, "outputs": 21053, "inputs": {"n": 13}}]