title: Dice Throw Problem
signature: function dice_throw_problem(m, n, x)
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 ];
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(m, n, x, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(m, n, x) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(94, 4, 69, 50116)
      print(string.format("TEST-0...%s",result))
  
      result = driver(7, 12, 33, 77635844)
      print(string.format("TEST-1...%s",result))
  
      result = driver(20, 44, 24, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(90, 94, 88, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(50, 58, 27, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(32, 90, 29, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(46, 25, 6, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(43, 82, 70, 0)
      print(string.format("TEST-7...%s",result))
  
      result = driver(6, 83, 19, 0)
      print(string.format("TEST-8...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 50116, "inputs": {"m": 94, "n": 4, "x": 69}}, {"idx": 1, "outputs": 77635844, "inputs": {"m": 7, "n": 12, "x": 33}}, {"idx": 2, "outputs": 0, "inputs": {"m": 20, "n": 44, "x": 24}}, {"idx": 3, "outputs": 0, "inputs": {"m": 90, "n": 94, "x": 88}}, {"idx": 4, "outputs": 0, "inputs": {"m": 50, "n": 58, "x": 27}}, {"idx": 5, "outputs": 0, "inputs": {"m": 32, "n": 90, "x": 29}}, {"idx": 6, "outputs": 0, "inputs": {"m": 46, "n": 25, "x": 6}}, {"idx": 7, "outputs": 0, "inputs": {"m": 43, "n": 82, "x": 70}}, {"idx": 8, "outputs": 0, "inputs": {"m": 6, "n": 83, "x": 19}}]
question_info.extension: lua
question_info.entry_fn_name: dice_throw_problem
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8
question_info.commands: lua __FILENAME__