title: Count Strings Adjacent Characters Difference One
signature: fun countStringsAdjacentCharactersDifferenceOne(n: Int): Long {
source_py: def count_strings_adjacent_characters_difference_one(n):
      dp = [[0 for j in range(27)] for i in range((n + 1))]
      for i in range(0, 26):
          dp[1][i] = 1
      for i in range(2, (n + 1)):
          for j in range(0, 26):
              if (j == 0):
                  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 i in range(0, 26):
          sum = (sum + dp[n][i])
      return sum
source_cpp: int count_strings_adjacent_characters_difference_one(int n) {
    long int dp [ n + 1 ] [ 27 ];
    memset ( dp, 0, sizeof ( dp ) );
    for ( int i = 0;
    i <= 25;
    i ++ ) dp [ 1 ] [ i ] = 1;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      for ( int j = 0;
      j <= 25;
      j ++ ) if ( j == 0 ) dp [ i ] [ j ] = dp [ i - 1 ] [ j + 1 ];
      else dp [ i ] [ j ] = ( dp [ i - 1 ] [ j - 1 ] + dp [ i - 1 ] [ j + 1 ] );
    }
    long int sum = 0;
    for ( int i = 0;
    i <= 25;
    i ++ ) sum = ( sum + dp [ n ] [ i ] );
    return sum;
  }
question_info.test_list: [{"idx": 0, "outputs": 1468, "inputs": {"n": 7}}, {"idx": 1, "outputs": 1134264891541288, "inputs": {"n": 47}}, {"idx": 2, "outputs": 544505079089235836, "inputs": {"n": 56}}, {"idx": 3, "outputs": 41103600, "inputs": {"n": 22}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Long, expected:Long):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Long):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(7, 1468)
      println("TEST-0...${result}")
      
      result = driver(47, 1134264891541288)
      println("TEST-1...${result}")
      
      result = driver(56, 544505079089235836)
      println("TEST-2...${result}")
      
      result = driver(22, 41103600)
      println("TEST-3...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: countStringsAdjacentCharactersDifferenceOne
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn