title: Dice Throw Problem 1
signature: class Solution {
  
      public long DiceThrowProblem1(int f, int d, int s) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(long actual, long expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(int f, int d, int s, long expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                long pred_result = solution_cls.PLACEHOLDER_FN_NAME(f, d, s); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  57, 5, 33, 
                  35960
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  58, 45, 4, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  38, 89, 9, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  5, 39, 30, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  91, 90, 47, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  76, 56, 46, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  97, 26, 52, 
                  247959266474052
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  97, 90, 90, 
                  1
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  99, 2, 26, 
                  25
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );
          }
      }
  }
  
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 ];
  }