title: Painting Fence Algorithm
signature: class Solution {
  
      public Integer paintingFenceAlgorithm(Integer n, Integer k) {
source_py: def painting_fence_algorithm(n, k):
      total = k
      mod = 1000000007
      (same, diff) = (0, k)
      for i in range(2, (n + 1)):
          same = diff
          diff = (total * (k - 1))
          diff = (diff % mod)
          total = ((same + diff) % mod)
      return total
source_cpp: long painting_fence_algorithm(int n, int k) {
    long total = k;
    int mod = 1000000007;
    int same = 0, diff = k;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      same = diff;
      diff = total * ( k - 1 );
      diff = diff % mod;
      total = ( same + diff ) % mod;
    }
    return total;
  }
question_info.extension: java
question_info.entry_fn_name: paintingFenceAlgorithm
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 725841870, "inputs": {"n": 6, "k": 30}}, {"idx": 1, "outputs": 370622679, "inputs": {"n": 23, "k": 87}}, {"idx": 2, "outputs": 7554776, "inputs": {"n": 89, "k": 31}}, {"idx": 3, "outputs": 76740139, "inputs": {"n": 63, "k": 36}}, {"idx": 4, "outputs": 647498520, "inputs": {"n": 23, "k": 68}}, {"idx": 5, "outputs": 70208793, "inputs": {"n": 44, "k": 66}}, {"idx": 6, "outputs": 227130467, "inputs": {"n": 81, "k": 18}}, {"idx": 7, "outputs": 204618786, "inputs": {"n": 43, "k": 73}}, {"idx": 8, "outputs": 797370673, "inputs": {"n": 9, "k": 42}}, {"idx": 9, "outputs": 903959704, "inputs": {"n": 41, "k": 98}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Integer k, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(6, 30, 725841870);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(23, 87, 370622679);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(89, 31, 7554776);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(63, 36, 76740139);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(23, 68, 647498520);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(44, 66, 70208793);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(81, 18, 227130467);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(43, 73, 204618786);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(9, 42, 797370673);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(41, 98, 903959704);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer k, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n, k),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__