title: Number N Digit Stepping Numbers
signature: numberNDigitSteppingNumbers :: Integer -> Integer
  numberNDigitSteppingNumbers n = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Integer -> Integer -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: Integer -> Integer -> String
  driver n expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME n) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver (18) (547810) )
  
      printf "TEST-1...%s\n" (driver (26) (100719775) )
  
      printf "TEST-2...%s\n" (driver (41) (1774846161206) )
  
      printf "TEST-3...%s\n" (driver (20) (2017126) )
  
      printf "TEST-4...%s\n" (driver (25) (52479500) )
  
      printf "TEST-5...%s\n" (driver (52) (2306507126768895) )
  
      printf "TEST-6...%s\n" (driver (13) (21053) )
  
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;
  }