Combinational Dice Rolls
Start Timer
0:00:00
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)
]
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments