mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
28 lines
794 B
Python
28 lines
794 B
Python
from .__init__ import *
|
|
from ..__init__ import Generator
|
|
|
|
|
|
def DiceSumProbFunc(maxDice=3):
|
|
a = random.randint(1, maxDice)
|
|
b = random.randint(a, 6 * a)
|
|
|
|
count = 0
|
|
for i in [1, 2, 3, 4, 5, 6]:
|
|
if a == 1:
|
|
if i == b:
|
|
count = count + 1
|
|
elif a == 2:
|
|
for j in [1, 2, 3, 4, 5, 6]:
|
|
if i + j == b:
|
|
count = count + 1
|
|
elif a == 3:
|
|
for j in [1, 2, 3, 4, 5, 6]:
|
|
for k in [1, 2, 3, 4, 5, 6]:
|
|
if i + j + k == b:
|
|
count = count + 1
|
|
|
|
problem = "If {} dice are rolled at the same time, the probability of getting a sum of {} =".format(
|
|
a, b)
|
|
solution = "{}/{}".format(count, 6**a)
|
|
return problem, solution
|