title: Dice Throw Problem
signature: dice_throw_problem <- function(m, n, x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(m, n, x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(m, n, x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          94L, 4L, 69L, 
          50116L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          7L, 12L, 33L, 
          77635844L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          20L, 44L, 24L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          90L, 94L, 88L, 
          0L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          50L, 58L, 27L, 
          0L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          32L, 90L, 29L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          46L, 25L, 6L, 
          0L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          43L, 82L, 70L, 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          6L, 83L, 19L, 
          0L
      )))
  
  }
  
  main()
source_py: def dice_throw_problem(m, n, x):
      table = [([0] * (x + 1)) for i in range((n + 1))]
      for j in range(1, min((m + 1), (x + 1))):
          table[1][j] = 1
      for i in range(2, (n + 1)):
          for j in range(1, (x + 1)):
              for k in range(1, min((m + 1), j)):
                  table[i][j] += table[(i - 1)][(j - k)]
      return table[(- 1)][(- 1)]
source_cpp: int dice_throw_problem(int m, int n, int x) {
    int table [ n + 1 ] [ x + 1 ];
    memset ( table, 0, sizeof ( table ) );
    for ( int j = 1;
    j <= m && j <= x;
    j ++ ) table [ 1 ] [ j ] = 1;
    for ( int i = 2;
    i <= n;
    i ++ ) for ( int j = 1;
    j <= x;
    j ++ ) for ( int k = 1;
    k <= m && k < j;
    k ++ ) table [ i ] [ j ] += table [ i - 1 ] [ j - k ];
    return table [ n ] [ x ];
  }