title: Dice Throw Problem 1
signature: dice_throw_problem_1 <- function(f, d, s) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(f, d, s, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(f, d, s), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          57L, 5L, 33L, 
          35960L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          58L, 45L, 4L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          38L, 89L, 9L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          5L, 39L, 30L, 
          0L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          91L, 90L, 47L, 
          0L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          76L, 56L, 46L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          97L, 26L, 52L, 
          247959266474052L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          97L, 90L, 90L, 
          1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          99L, 2L, 26L, 
          25L
      )))
  
  }
  
  main()
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 ];
  }