Einzelnen Beitrag anzeigen

Marcel2906

Registriert seit: 17. Aug 2011
Ort: Warendorf
112 Beiträge
 
Delphi 2010 Professional
 
#4

AW: Sudoku Kandidaten löschen

  Alt 10. Nov 2011, 14:39
hab mein Fehler endeckt:
Hier die Lösung:

Delphi-Quellcode:
            // Feld 1 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a < 3) And (b < 3) Then Begin
               For x := 0 To 2 Do
                  For y := 0 To 2 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
            // Feld 2 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a < 3) And (b > 3) And (b < 6) Then Begin
               For x := 0 To 2 Do
                  For y := 3 To 5 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
            // Feld 3 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a < 3) And (b > 5) Then Begin
               For x := 0 To 2 Do
                  For y := 6 To 8 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;

            // Feld 4 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a > 2) And (a < 6) And (b < 3) Then Begin
               For x := 3 To 5 Do
                  For y := 0 To 2 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
            // Feld 5 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a > 2) And (a < 6) And (b > 3) And (b < 6) Then Begin
               For x := 3 To 5 Do
                  For y := 3 To 5 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
            // Feld 6 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a > 2) And (a < 6) And (b > 5) Then Begin
               For x := 3 To 5 Do
                  For y := 6 To 8 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;

            // Feld 7 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a > 5) And (b < 3) Then Begin
               For x := 6 To 8 Do
                  For y := 0 To 2 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
            // Feld 8 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a > 5) And (b > 2) And (b < 6) Then Begin
               For x := 6 To 8 Do
                  For y := 3 To 5 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
            // Feld 9 nach Werten durchsuchen und aus Kandidatenliste löschen
            If (a > 5) And (b > 5) Then Begin
               For x := 6 To 8 Do
                  For y := 6 To 8 Do
                     If aSudoku[x, y] < 10 Then Begin
                        s := IntToStr(aSudoku[a, b]);
                        ss := IntToStr(aSudoku[x, y]);
                        s := Stringreplace(s, ss, '', [rfReplaceAll]);
                        aSudoku[a, b] := StrToInt(s);
                     End;
            End;
  Mit Zitat antworten Zitat