import csv from itertools import combinations import time print("=== EUROJACKPOT KOMBINATIONS-GENERATOR ===") print("Erstellt alle möglichen Kombinationen mit Status (gezogen/nicht gezogen)") print() # Pfade eurojackpot_file = '/Users/sebastianfrohlich/Downloads/EJ_ab_2018.csv' output_file = '/Users/sebastianfrohlich/Desktop/Alle_Eurojackpot_Kombinationen_mit_Status.csv' missing_file = '/Users/sebastianfrohlich/Desktop/Fehlende_Eurojackpot_Kombinationen.csv' # Schritt 1: Einlesen der gezogenen Kombinationen print("Schritt 1: Lade gezogene Eurojackpot-Kombinationen...") existing_combinations = set() try: with open(eurojackpot_file, 'r', encoding='utf-8') as file: lines = file.readlines() for line in lines[1:]: # Header überspringen parts = line.strip().split(';') if len(parts) >= 6: # Mindestens Datum + 5 Zahlen try: numbers = [] for i in range(1, 6): # Spalten 1-5 (nach Datum) if i < len(parts) and parts[i].strip().isdigit(): numbers.append(int(parts[i].strip())) if len(numbers) == 5: # Vollständige Kombination combo = frozenset(numbers) existing_combinations.add(combo) except (ValueError, IndexError): continue print(f" ✓ {len(existing_combinations)} gezogene Kombinationen geladen") # Beispiele anzeigen if existing_combinations: print(" Beispiele:") for i, combo in enumerate(list(existing_combinations)[:3]): sorted_combo = sorted(list(combo)) print(f" {sorted_combo}") if len(existing_combinations) > 3: print(f" ... und {len(existing_combinations)-3} weitere") except FileNotFoundError: print(f" ⚠️ Datei nicht gefunden: {eurojackpot_file}") existing_combinations = set() except Exception as e: print(f" ⚠️ Fehler beim Lesen: {e}") existing_combinations = set() print() # Schritt 2: Generierung aller möglichen Kombinationen print("Schritt 2: Generiere alle möglichen Kombinationen (5 aus 50)...") total_combinations = 2118760 # C(50,5) print(f" Gesamtanzahl zu verarbeitender Kombinationen: {total_combinations:,}") all_combinations = [] count = 0 start_time = time.time() for combo in combinations(range(1, 51), 5): count += 1 # Fortschritt anzeigen if count % 100000 == 0: elapsed = time.time() - start_time rate = count / elapsed if elapsed > 0 else 0 remaining = (total_combinations - count) / rate if rate > 0 else 0 print(f" Fortschritt: {count:,} / {total_combinations:,} " f"({count/total_combinations*100:.1f}%) " f"- {rate:,.0f}/s - noch ~{remaining/60:.1f} min") # Prüfen ob Kombination bereits gezogen wurde sorted_combo = sorted(combo) is_drawn = 1 if frozenset(combo) in existing_combinations else 0 # Zur Liste hinzufügen (Z1, Z2, Z3, Z4, Z5, gezogen) combination_row = sorted_combo + [is_drawn] all_combinations.append(combination_row) print(f" ✓ Alle {len(all_combinations):,} Kombinationen generiert") print() # Schritt 3: Statistiken berechnen print("Schritt 3: Berechne Statistiken...") drawn_combinations = sum(1 for combo in all_combinations if combo[5] == 1) undrawn_combinations = len(all_combinations) - drawn_combinations print(f" Gesamt mögliche Kombinationen: {len(all_combinations):,}") print(f" Bereits gezogene Kombinationen: {drawn_combinations:,}") print(f" Noch nicht gezogene Kombinationen: {undrawn_combinations:,}") if len(all_combinations) > 0: percentage = drawn_combinations / len(all_combinations) * 100 print(f" Anteil gezogener Kombinationen: {percentage:.6f}%") print() # Schritt 4: Hauptdatei speichern print("Schritt 4: Speichere Hauptdatei...") try: with open(output_file, 'w', newline='', encoding='utf-8') as outfile: writer = csv.writer(outfile, delimiter=';') writer.writerow(['Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'gezogen']) # Header for combo in all_combinations: writer.writerow(combo) print(f" ✓ Hauptdatei gespeichert: {output_file}") except Exception as e: print(f" ⚠️ Fehler beim Speichern der Hauptdatei: {e}") # Schritt 5: Datei mit fehlenden Kombinationen speichern print("Schritt 5: Speichere Datei mit fehlenden Kombinationen...") try: missing_combinations = [combo[:5] for combo in all_combinations if combo[5] == 0] with open(missing_file, 'w', newline='', encoding='utf-8') as outfile: writer = csv.writer(outfile, delimiter=';') writer.writerow(['Z1', 'Z2', 'Z3', 'Z4', 'Z5']) # Header for combo in missing_combinations: writer.writerow(combo) print(f" ✓ Datei mit fehlenden Kombinationen gespeichert: {missing_file}") print(f" ✓ {len(missing_combinations):,} fehlende Kombinationen") except Exception as e: print(f" ⚠️ Fehler beim Speichern der fehlenden Kombinationen: {e}") print() print("=== FERTIG ===") print("Erstellte Dateien:") print(f"1. {output_file}") print(f" - Alle {len(all_combinations):,} Kombinationen mit Status") print(f"2. {missing_file}") if 'missing_combinations' in locals(): print(f" - {len(missing_combinations):,} noch nicht gezogene Kombinationen") print() print("Format der Hauptdatei:") print("Z1;Z2;Z3;Z4;Z5;gezogen") print("1;2;3;4;5;0") print("...")