mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
26 lines
651 B
Python
26 lines
651 B
Python
from .__init__ import *
|
|
|
|
|
|
def combinationsFunc(maxlength=20, format='string'):
|
|
def factorial(a):
|
|
d = 1
|
|
for i in range(a):
|
|
a = (i + 1) * d
|
|
d = a
|
|
return d
|
|
|
|
a = random.randint(10, maxlength)
|
|
b = random.randint(0, 9)
|
|
|
|
solution = int(factorial(a) / (factorial(b) * factorial(a - b)))
|
|
|
|
if format == 'string':
|
|
problem = f"Number of combinations from {a} objects picked {b} at a time "
|
|
return problem, str(solution)
|
|
else:
|
|
return a, b, solution
|
|
|
|
|
|
combinations = Generator("Combinations of Objects", 30, combinationsFunc,
|
|
["maxlength=20"])
|