title: Dice Throw Problem 1
signature: class Solution {
  
      public Long diceThrowProblem1(Integer f, Integer d, Integer s) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer f, Integer d, Integer s, Long expected){
          try{
              Driver driver = new Driver();
              if (driver.run(f, d, s,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(57, 5, 33, 35960L);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(58, 45, 4, 0L);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(38, 89, 9, 0L);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(5, 39, 30, 0L);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(91, 90, 47, 0L);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(76, 56, 46, 0L);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(97, 26, 52, 247959266474052L);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(97, 90, 90, 1L);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(99, 2, 26, 25L);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer f, Integer d, Integer s, Long expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(f, d, s),expected);
      }
      
      public boolean validateSolution(Long actual, Long expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def dice_throw_problem_1(f, d, s):
      mem = [[0 for i in range((s + 1))] for j in range((d + 1))]
      mem[0][0] = 1
      for i in range(1, (d + 1)):
          for j in range(1, (s + 1)):
              mem[i][j] = (mem[i][(j - 1)] + mem[(i - 1)][(j - 1)])
              if (((j - f) - 1) >= 0):
                  mem[i][j] -= mem[(i - 1)][((j - f) - 1)]
      return mem[d][s]
source_cpp: long dice_throw_problem_1(int f, int d, int s) {
    long mem [ d + 1 ] [ s + 1 ];
    memset ( mem, 0, sizeof mem );
    mem [ 0 ] [ 0 ] = 1;
    for ( int i = 1;
    i <= d;
    i ++ ) {
      for ( int j = i;
      j <= s;
      j ++ ) {
        mem [ i ] [ j ] = mem [ i ] [ j - 1 ] + mem [ i - 1 ] [ j - 1 ];
        if ( j - f - 1 >= 0 ) mem [ i ] [ j ] -= mem [ i - 1 ] [ j - f - 1 ];
      }
    }
    return mem [ d ] [ s ];
  }