Interview Query

Combinational Dice Rolls

0
Have you seen this question before?

Given n dice each with m faces, write a function combinational_dice_rolls to dump all possible combinations of dice rolls. 

Bonus: Can you do it recursively?

Example 1:

Input:

n = 2
m = 2

Output:

def combinational_dice_rolls(n, m) -> [
    (1,1), (1,2), (2,1), (2,2)
]

Example 2:

Input:

n = 3
m = 2

Output:

def combinational_dice_rolls(n, m) -> [
    (1,1,1),(2,1,1),(1,2,1),(1,1,2),
    (2,2,1),(1,2,2),(2,1,2),(2,2,2)
]
Next question: Estimated Rounds
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code