hallo!
Ich bin absoluter Anfänger und hab mal eine Frage:
Ich möchte alle Zahlenkombinationen von 5 aus 50 (Euromillionen) ohne 2 aus 11. Gibt es die Möglichkeit einer solchen Datei über ein makro zu erstellen? Oder würde das den Rahmen eines Tabellendokuments sprengen?
mfg hansi
5 aus 50
Moderator: Moderatoren
Re: 5 aus 50
Dieses makro habe ich im Internet gefunden (6 aus 49). Kann man das eventuell umschreiben auf 5 aus 50????
http://www.herber.de/forum/archiv/236to ... ionen.html
Sub Lotto_moegliche_Kombinationen()
Dim i As Byte, j As Byte, k As Byte, l As Byte, m As Byte, n As Byte
Dim c As Integer, r As Long
r = 1
c = 1
Application.ScreenUpdating = False
For i = 1 To 49 For j = i + 1 To 49
For k = j + 1 To 49
For l = k + 1 To 49
For m = l + 1 To 49
For n = m + 1 To 49
Cells(r, c) = i & " " & j & " " & k & " " & l & " " & m & " " & n
r = r + 1
If r > 65536 Then
Application.ScreenUpdating = True
c = c + 1
r = 1
ThisWorkbook.Save
If c > 256 Then
c = 1
Worksheets.Add
End If
Application.ScreenUpdating = False
End If
Next
Next
Next
Next
Next
Next
End Sub
danke im Voraus
Hansi
http://www.herber.de/forum/archiv/236to ... ionen.html
Sub Lotto_moegliche_Kombinationen()
Dim i As Byte, j As Byte, k As Byte, l As Byte, m As Byte, n As Byte
Dim c As Integer, r As Long
r = 1
c = 1
Application.ScreenUpdating = False
For i = 1 To 49 For j = i + 1 To 49
For k = j + 1 To 49
For l = k + 1 To 49
For m = l + 1 To 49
For n = m + 1 To 49
Cells(r, c) = i & " " & j & " " & k & " " & l & " " & m & " " & n
r = r + 1
If r > 65536 Then
Application.ScreenUpdating = True
c = c + 1
r = 1
ThisWorkbook.Save
If c > 256 Then
c = 1
Worksheets.Add
End If
Application.ScreenUpdating = False
End If
Next
Next
Next
Next
Next
Next
End Sub
danke im Voraus
Hansi
Re: 5 aus 50
Hallo
Die Möglichkeit gibt es - was hast du davon 2118760 mögliche kombinationen in einer Datei anzuschauen ??
Karolus
Die Möglichkeit gibt es - was hast du davon 2118760 mögliche kombinationen in einer Datei anzuschauen ??
Karolus
LO7.4.7.2 debian 12(bookworm) auf Raspberry5 8GB (ARM64)
LO25.2.3.2 flatpak debian 12(bookworm) auf Raspberry5 8GB (ARM64)
LO25.2.3.2 flatpak debian 12(bookworm) auf Raspberry5 8GB (ARM64)
Re: 5 aus 50
hallo!
und wie würde das gehen???
ich nutze diese Zahlenkombinationen in Verbindung mit anderen mathematischen Systeme.
mfg
und wie würde das gehen???
ich nutze diese Zahlenkombinationen in Verbindung mit anderen mathematischen Systeme.
mfg
Re: 5 aus 50
Aha!!hansi26 hat geschrieben: ich nutze diese Zahlenkombinationen in Verbindung mit anderen mathematischen Systeme.
Code: Alles auswählen
import uno
from os import path
from itertools import combinations
ctx = uno.getComponentContext()
servicemanager = ctx.ServiceManager
createUnoService = servicemanager.createInstance
file_access = createUnoService("com.sun.star.ucb.SimpleFileAccess")
pathsubstution = createUnoService("com.sun.star.util.PathSubstitution")
def install_me(*_):
"""
Funktion zum kopieren dieses eingebetteten Pythonscripts
ins den .userconfig_python_pfad"""
pythonfolder = pathsubstution.substituteVariables('$(user)/Scripts/python/',0)
filename = path.basename(__file__)
if not file_access.isFolder( pythonfolder):
file_access.createFolder(pythonfolder)
file_access.copy(__file__, path.join( pythonfolder, filename))
def setcombi():
"""
Schreibt alle Kombinationsmoeglichkeiten aus 5 aus 50
in ein Tabellenblatt
Aufteilung 4 Bloecke, zu je 5 Spalten * 529690 Zeilen, nebeneinander.
"""
allcombis = tuple( x for x in combinations(range(1,51), 5))
quo = int(len(allcombis)/4)
doc = XSCRIPTCONTEXT.getDocument()
sheet = doc.Sheets.getByIndex(0)
for c, s in zip([0, 6, 12, 18],[1,2,3,4]):
crange = sheet.getCellRangeByPosition(c,0,c+4,529689)
crange.DataArray = allcombis[(s-1)*quo:s*quo]
Karolus
- Dateianhänge
-
- 5aus50_kombinationen.ods
- (11.09 KiB) 56-mal heruntergeladen
LO7.4.7.2 debian 12(bookworm) auf Raspberry5 8GB (ARM64)
LO25.2.3.2 flatpak debian 12(bookworm) auf Raspberry5 8GB (ARM64)
LO25.2.3.2 flatpak debian 12(bookworm) auf Raspberry5 8GB (ARM64)
Re: 5 aus 50
Vielen vielen Dank für die schnelle Antwort!!!! Falls ich zum Erfolg komme bist du der erste der davon profitiert!!!
)
Danke

Danke