9 lines
205 B
Python
9 lines
205 B
Python
import random
|
|
|
|
|
|
def roll_dice(spec):
|
|
return sum(
|
|
sum(random.randint(1, int(a)) for _ in range(int(b))) if b else int(a)
|
|
for a, _, b in (s.partition("d") for s in spec.split("+"))
|
|
)
|