Thema Datum  Von Nutzer Rating
Antwort
Rot nochmals verschachtelte Schleifen
06.02.2015 20:26:00 Hans Dampf
NotSolved
06.02.2015 21:35:11 Gast35625
NotSolved
06.02.2015 21:38:07 Gast79710
NotSolved
06.02.2015 21:52:01 Gast34882
NotSolved
06.02.2015 21:57:15 Gast16907
NotSolved
06.02.2015 23:13:41 Gast46146
NotSolved
07.02.2015 01:04:38 Gast56536
NotSolved
08.02.2015 09:30:27 Gast31315
NotSolved

Ansicht des Beitrags:
Von:
Hans Dampf
Datum:
06.02.2015 20:26:00
Views:
1367
Rating: Antwort:
  Ja
Thema:
nochmals verschachtelte Schleifen

Hallo ich nochmals

Die Problemstellung neu erörtert:

Die Zaheln 0 bis 10 müssen B0 bis B10 zugeordnet werden. Folgende Bedingungen gelten:

z0 = B1 + B5 + B4 + B8 + B3
z1 = B0 + B6 + B2
z2 = B1 + B10
z3 = B0 + B8
z4 = B0 + B5 + B6
z5 = B0 + B4 + B6 + B10
z6 = B8 + B4 + B1 + B5 + B7 + B9
z7 = B6 + B10
z8 = B0 + B3 + B6 + B9
z9 = B8 + B6 + B10
z10 = B9 + B7 + B5 + B2

Bei welchen B0 bis B10 ist folgende Gleichnung erfüllt:

z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9 + z10 = 195

Habe mir folgendes überlegt, leider brauchen diese Schleifen so lange, dass ich noch auf keine Resultate gekommen bin:

Sub Schleife()
Dim B0 As Long, B1 As Long, B2 As Long, B3 As Long, B4 As Long, B5 As Long, B6 As Long, B7 As Long, B8 As Long, B9 As Long, B10 As Long
Dim z0 As Long, z1 As Long, z2 As Long, z3 As Long, z4 As Long, z5 As Long, z6 As Long, z7 As Long, z8 As Long, z9 As Long, z10 As Long
Dim s As String

For B10 = 0 To 10
    For B9 = 0 To 10
        For B8 = 0 To 9
            For B7 = 0 To 9
                For B6 = 0 To 9
                    For B5 = 0 To 10
                        For B4 = 0 To 9
                            For B3 = 0 To 9
                                For B2 = 0 To 10
                                    For B1 = 0 To 9
                                        For B0 = 0 To 10
If B10 <> B9 Then
If B10 <> B8 Then
If B10 <> B7 Then
If B10 <> B6 Then
If B10 <> B5 Then
If B10 <> B4 Then
If B10 <> B3 Then
If B10 <> B2 Then
If B10 <> B1 Then
If B10 <> B0 Then
If B9 <> B8 Then
If B9 <> B7 Then
If B9 <> B6 Then
If B9 <> B5 Then
If B9 <> B4 Then
If B9 <> B3 Then
If B9 <> B2 Then
If B9 <> B1 Then
If B9 <> B0 Then
If B8 <> B7 Then
If B8 <> B6 Then
If B8 <> B5 Then
If B8 <> B4 Then
If B8 <> B3 Then
If B8 <> B2 Then
If B8 <> B1 Then
If B8 <> B0 Then
If B7 <> B6 Then
If B7 <> B5 Then
If B7 <> B4 Then
If B7 <> B3 Then
If B7 <> B2 Then
If B7 <> B1 Then
If B7 <> B0 Then
If B6 <> B5 Then
If B6 <> B4 Then
If B6 <> B3 Then
If B6 <> B2 Then
If B6 <> B1 Then
If B6 <> B0 Then
If B5 <> B4 Then
If B5 <> B3 Then
If B5 <> B2 Then
If B5 <> B1 Then
If B5 <> B0 Then
If B4 <> B3 Then
If B4 <> B2 Then
If B4 <> B1 Then
If B4 <> B0 Then
If B3 <> B2 Then
If B3 <> B1 Then
If B3 <> B0 Then
If B2 <> B1 Then
If B2 <> B0 Then
If B1 <> B0 Then
                                                z0 = B1 + B5 + B4 + B8 + B3
                                                z1 = B0 + B6 + B2
                                                z2 = B1 + B10
                                                z3 = B0 + B8
                                                z4 = B0 + B5 + B6
                                                z5 = B0 + B4 + B6 + B10
                                                z6 = B8 + B4 + B1 + B5 + B7 + B9
                                                z7 = B6 + B10
                                                z8 = B0 + B3 + B6 + B9
                                                z9 = B8 + B6 + B10
                                                z10 = B9 + B7 + B5 + B2
                                                If z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9 + z10 = 195 Then
                                                    s = s & B0 & ", " & B1 & ", " & B2 & ", " & B3 & ", " & B4 & ", " & B5 & ", " & B6 & ", " & B7 & ", " & B8 & ", " & B9 & ", " & B10 & vbLf
                                                End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
                                        Next B0
                                    Next B1
                                Next B2
                            Next B3
                        Next B4
                    Next B5
                Next B6
            Next B7
        Next B8
    Next B9
Next B10
    MsgBox s
End Sub
    MsgBox s
End Sub

Wie kann ich das schneller machen? Oder hat jemand eine andere Lösung in Peto? Was ist die Lösung for B0 bis B10?

Gruss Hans


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot nochmals verschachtelte Schleifen
06.02.2015 20:26:00 Hans Dampf
NotSolved
06.02.2015 21:35:11 Gast35625
NotSolved
06.02.2015 21:38:07 Gast79710
NotSolved
06.02.2015 21:52:01 Gast34882
NotSolved
06.02.2015 21:57:15 Gast16907
NotSolved
06.02.2015 23:13:41 Gast46146
NotSolved
07.02.2015 01:04:38 Gast56536
NotSolved
08.02.2015 09:30:27 Gast31315
NotSolved