You have n dices each one having s sides numbered from 1 to s.
How many outcomes add up to a specified number k?

For example if we roll four normal six-sided dices we
have four outcomes that add up to 5. 

(1, 1, 1, 2)
(1, 1, 2, 1)
(1, 2, 1, 1)
(2, 1, 1, 1)

Difficulty: introductory

Starter code:

def outcome(n, s, k):
	

Solutions:
def outcome(n, s, k):    
    if n == 1: return 1 if 0 < k <= s else 0
    return sum(outcome(n - 1, s, k - j - 1) for j in range(s)) if k > 0 else 0

def outcome(n, s, k):
    return n <= k <= n*s and (n in (1, k) or sum(outcome(n-1, s, k-x-1) for x in range(min(s, k-n+1))))

def outcome(n, s, k):
    if n == 0:
        return k == 0
    return sum(outcome(n-1, s, k-i) for i in range(1, s+1)) if n <= k <= s * n else 0

def outcome(n, s, k):

    if n * s * k == 0: 
        return 0
    
    dp = [[0] * (k + 1) for i in range(n + 1)]
    
    for i in range(1, min(s + 1, k + 1)): 
        dp[1][i] = 1
    
    for i in range(2, n + 1): 
        for j in range(1, k + 1): 
            for l in range(1, min(s + 1, j)): 
                dp[i][j] += dp[i - 1][j - l]
      
    return dp.pop().pop()

from itertools import product

def outcome(n, s, k):
    return sum(1 for roll in product(range(1, s + 1), repeat=n) if sum(roll) == k) 

def outcome(n, s, k):
    from itertools import zip_longest
    dice = [1]
    for _ in range(n):
        dice = [sum(x) for x in zip_longest(*([0] * i + dice for i in range(1, s+1)), fillvalue=0)]
    return dice[k] if k < len(dice) else 0



def outcome(n, s, k):
    return 0 < k <= s if n == 1 else sum(outcome(n-1, s, k-v) for v in range(1, min(k-(n-1),s)+1) if k-v > 0)

from itertools import product
def outcome(n, s, k):
    return sum(sum(x) == k for x in product(range(1, s + 1), repeat=n))

outcome=o=lambda n,s,k:s>=k>0if n==1else sum(o(n-1,s,k-i-1)for i in range(min(s,k)))

from itertools import product

def outcome(n, s, k):
    return sum( sum(p) == k for p in product(range(1, s+1), repeat=n) )