Switch für das erlauben gleicher Nenner hinzugefügt.
This commit is contained in:
		@@ -19,7 +19,7 @@ NUM_QUESTIONS = 5
 | 
			
		||||
# Algebraische Struktur der Aufgaben
 | 
			
		||||
STRUCTURE = "(-)-(+(-))"
 | 
			
		||||
# Gleiche Nenner erlauben
 | 
			
		||||
# TODO
 | 
			
		||||
SAME_ALLOWED = True
 | 
			
		||||
# Größter Zähler
 | 
			
		||||
MAX_NUMERATOR = 10
 | 
			
		||||
# Größter Nenner
 | 
			
		||||
@@ -179,17 +179,22 @@ def create_formula_question(ex_number: int):
 | 
			
		||||
        numerators.append(n)
 | 
			
		||||
        denominators.append(d)
 | 
			
		||||
 | 
			
		||||
    # Sicherstellen, dass die Nenner unterschiedlich sind
 | 
			
		||||
    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)
 | 
			
		||||
    # Müssen Nenner unterschiedlich sein?
 | 
			
		||||
    if not SAME_ALLOWED:
 | 
			
		||||
        # Sicherstellen, dass die Nenner unterschiedlich sind
 | 
			
		||||
        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]
 | 
			
		||||
    print(numerators)
 | 
			
		||||
    print(denominators)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user