Switch für das erlauben gleicher Nenner hinzugefügt.
This commit is contained in:
parent
f2797ae8d2
commit
2f72fccc6a
@ -19,7 +19,7 @@ NUM_QUESTIONS = 5
|
|||||||
# Algebraische Struktur der Aufgaben
|
# Algebraische Struktur der Aufgaben
|
||||||
STRUCTURE = "(-)-(+(-))"
|
STRUCTURE = "(-)-(+(-))"
|
||||||
# Gleiche Nenner erlauben
|
# Gleiche Nenner erlauben
|
||||||
# TODO
|
SAME_ALLOWED = True
|
||||||
# Größter Zähler
|
# Größter Zähler
|
||||||
MAX_NUMERATOR = 10
|
MAX_NUMERATOR = 10
|
||||||
# Größter Nenner
|
# Größter Nenner
|
||||||
@ -179,17 +179,22 @@ def create_formula_question(ex_number: int):
|
|||||||
numerators.append(n)
|
numerators.append(n)
|
||||||
denominators.append(d)
|
denominators.append(d)
|
||||||
|
|
||||||
# Sicherstellen, dass die Nenner unterschiedlich sind
|
# Müssen Nenner unterschiedlich sein?
|
||||||
same_denominators = [k for k,v in Counter(denominators).items() if v>1]
|
if not SAME_ALLOWED:
|
||||||
while len(same_denominators) > 1:
|
# Sicherstellen, dass die Nenner unterschiedlich sind
|
||||||
new_denom = random.randint(2, MAX_DENOMINATOR)
|
|
||||||
try:
|
|
||||||
index = denominators.index(same_denominators[0])
|
|
||||||
denominators[index] = new_denom
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
# denominators.replace(same_denominators[0], new_denom)
|
|
||||||
same_denominators = [k for k,v in Counter(denominators).items() if v>1]
|
same_denominators = [k for k,v in Counter(denominators).items() if v>1]
|
||||||
|
while len(same_denominators) > 1:
|
||||||
|
new_denom = random.randint(2, MAX_DENOMINATOR)
|
||||||
|
try:
|
||||||
|
index = denominators.index(same_denominators[0])
|
||||||
|
denominators[index] = new_denom
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
# denominators.replace(same_denominators[0], new_denom)
|
||||||
|
same_denominators = [k for k,v in Counter(denominators).items() if v>1]
|
||||||
|
else:
|
||||||
|
# keine Änderung / Ersetzung nötig
|
||||||
|
pass
|
||||||
# [DEBUG]
|
# [DEBUG]
|
||||||
print(numerators)
|
print(numerators)
|
||||||
print(denominators)
|
print(denominators)
|
||||||
|
Loading…
Reference in New Issue
Block a user