title: Dice Throw Problem 1
signature: func diceThrowProblem1(f int, d int, s int) int64 {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int64, expected int64) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(f int, d int, s int, expected int64) string {
      if validateSolution(PLACEHOLDER_FN_NAME(f, d, s),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(57, 
  	5, 
  	33, 35960)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(58, 
  	45, 
  	4, 0)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(38, 
  	89, 
  	9, 0)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(5, 
  	39, 
  	30, 0)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(91, 
  	90, 
  	47, 0)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(76, 
  	56, 
  	46, 0)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(97, 
  	26, 
  	52, 247959266474052)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(97, 
  	90, 
  	90, 1)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(99, 
  	2, 
  	26, 25)
      fmt.Printf("TEST-8...%s\n", 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 ];
  }