title: Dice Throw Problem 1
signature: long long diceThrowProblem1(int f, int d, int s) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(long long actual, long long expected){
      return actual == expected;
  }
  
  string driver(int f, int d, int s, long long expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(f, d, s), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(57, 5, 33, 35960); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(58, 45, 4, 0); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(38, 89, 9, 0); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(5, 39, 30, 0); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(91, 90, 47, 0); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(76, 56, 46, 0); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(97, 26, 52, 247959266474052); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(97, 90, 90, 1); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(99, 2, 26, 25); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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 ];
  }