Sudoku funktioniert nicht

  • So

    hab jetz ma angefangen n sudoku zu schreiben

    dass vertikal nie die gleiche zahl steht hab ich schon geschaft

    aba horizontal funzt das nich


    Spoiler anzeigen

    [autoit#include <GUIConstantsEx.au3>

    Global $n = 0, $Input[81], $l
    Global $nu[81]
    For $p = 0 To 80
    $nu[$p] = 0
    Next
    $Form1 = GUICreate("Form1", 297, 297, 369, 324)
    For $r = 0 To 8 Step 1
    For $c = 0 To 8 Step 1
    $Input[$n] = GUICtrlCreateInput("", 8+ 32*$r, 8+ 32*$c, 25, 21)
    GUICtrlSetLimit ( $Input[$n], 1)
    $n = $n + 1
    Next
    Next
    GUISetState(@SW_hide)
    For $n = 0 to 80 Step 1
    Do
    Switch $n
    Case 0 to 8
    While 1
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 0 to 8 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf

    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 9 to 17
    While 2
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 9 to 17 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 18 to 26
    While 3
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 19 to 26 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 27 to 35
    While 4
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 27 to 35 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 36 to 44
    While 5
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 36 to 44 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 45 to 53
    While 6
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 45 to 53 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 54 to 62
    While 7
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 54 to 62 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 63 to 71
    While 8
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 63 to 71 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else
    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0
    Case 72 to 80
    While 9
    $r = Random(1, 9, 1)
    For $n2 = 0 to 72 Step 9
    For $n1 = 72 to 80 Step 1
    If $r = $nu[$n1] or $r = $nu[Int($n/9)+$n2] Then
    $ok = 0
    ExitLoop
    Else


    $ok = 1

    EndIf
    Next
    Next
    If $ok = 1 Then
    $nu[$n] = $r
    ExitLoop
    EndIf

    WEnd
    $l = 0

    EndSwitch
    Until $nu[$n] = 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9
    Next
    For $z = 0 To 80
    GUICtrlSetData($Input[$z], $nu[$z])
    Next
    GUISetState(@sw_show, $Form1)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd[/autoit]


    Hat jmd ne lösung?


    Freu mich schon auf antworten