Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Sudoku (https://www.delphipraxis.net/60660-sudoku.html)

Poempel 10. Jan 2006 17:32


Sudoku
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hi,
also erstmal vorweg: Ich habe so ziemlich keine Ahnung von Delphi, mir hats nur mein Bruder mitgebracht und mir gezeigt wie man was macht, aber ich habs nicht kappiert :-D
Naja. Ich wollte mir auch mal gerne ein Programm programmieren das Sudokus löst. Damit habe ich, bzw. mein Bruder, auch schon angefangen, jetzt ist er aber wieder weg und nun sitze ich hier. Jetzt wollte ich mal fragen ob mir hier einer weiter helfen kann.

MFG und vielen Dank

Poempel


PS: Wie gesagt, ich habe keine Ahnung und achso, ja ich habe Delphi 7 Enterprise!

DP-Maintenance 10. Jan 2006 17:36

DP-Maintenance
 
Dieses Thema wurde von "flomei" von "Open-Source" nach "Sonstige Fragen zu Delphi" verschoben.
Die Sparte Open-Source ist für fertige Software gedacht, hier ist der Beitrag hoffentlich besser aufgehoben...

Stanlay Hanks 10. Jan 2006 17:45

Re: Sudoku
 
Hi. Wobei sollen wir dir helfen? Du musst schon dein Problem konkretisieren, eine dpr Datei hilft da wenig ;)

Man liest sich, Stanlay :hi:

Poempel 10. Jan 2006 17:53

Re: Sudoku
 
Ok, wie gesagt, ich habe null Ahnung und will nur damit was ich jetzt schon habe fertig werden. Was brauchst du denn um zu sehen was ich bisher schon habe???

MFG Poempel

hanselmansel 10. Jan 2006 18:00

Re: Sudoku
 
Aus der DPR können wir nicht sehen, was du für Quelltext hast, da Delphi auch andere PAS-Dateien öffnet, wenn du auf die DPR klickst. Die fehlen uns jetzt.
Du kannst aber auch den Quellcode aus Delphi markieren und mittels Copy&Pase in deinen Beitrag einbauen. Hierbei ist es dann wichtig, dass du den Code innerhalb von [ delphi]-Tags setzt. Dadurch wird er schön formatiert (von der Forensoftware) und wir können ihn gut lesen.

3_of_8 10. Jan 2006 18:04

Re: Sudoku
 
Ich denke mal, mit "lösen" meinst du bruteforcen???

Stanlay Hanks 10. Jan 2006 18:13

Re: Sudoku
 
Hier mal eine nützliche Übersicht zu Delphi: Klick!
Und hier eine Erläuterung zu Schleifen, die du für die Lösung deines Problems brauchen wirst, wenn du dich noch gar nicht mit Schleifen befasst hast: Klick!

Man liest sich, Stanlay :hi:

hanselmansel 10. Jan 2006 18:16

Re: Sudoku
 
Zitat:

Zitat von 3_of_8
bruteforcen

Nicht unbedingt. Ich habe schon hier in der DP Algorithmen gesehen, die mit Mengenoperationen arbeiten.
Sollte Poempel also die eine oder andere Idee suchen, so würde ich ihm empfehlen, die Suche der DP nach Hier im Forum suchenSudoku zu bemühen. :thumb:

3_of_8 10. Jan 2006 18:21

Re: Sudoku
 
Also ich setze da lieber aufs gute alte Bruteforcen. Komplizierte Algorithmen sind immer so...kompliziert.

dahead 10. Jan 2006 18:23

Re: Sudoku
 
Zitat:

Zitat von 3_of_8
Also ich setze da lieber aufs gute alte Bruteforcen. Komplizierte Algorithmen sind immer so...kompliziert.

allerdings auch schneller.

Poempel 12. Jan 2006 12:54

Re: Sudoku
 
Zitat:

Zitat von hanselmansel
Du kannst aber auch den Quellcode aus Delphi markieren und mittels Copy&Pase in deinen Beitrag einbauen. Hierbei ist es dann wichtig, dass du den Code innerhalb von [ delphi]-Tags setzt. Dadurch wird er schön formatiert (von der Forensoftware) und wir können ihn gut lesen.




Wie mache ich das denn?

MFG Poempel

3_of_8 12. Jan 2006 12:59

Re: Sudoku
 
Ich denke, das wurde bereits mehrmals gesagt.

[ delphi]
program Bla;

begin
writeln('irgendwas');
end.
[/delphi]

wird zu:

Delphi-Quellcode:
program Bla;

begin
writeln('irgendwas');
end.
Das Leerzeichen bei dem [ delphi] Tag am Anfang bitte weglassen.

Oxmyx 12. Jan 2006 13:00

Re: Sudoku
 
Zitat:

Zitat von Poempel
Zitat:

Zitat von hanselmansel
Du kannst aber auch den Quellcode aus Delphi markieren und mittels Copy&Pase in deinen Beitrag einbauen. Hierbei ist es dann wichtig, dass du den Code innerhalb von [ delphi]-Tags setzt. Dadurch wird er schön formatiert (von der Forensoftware) und wir können ihn gut lesen.




Wie mache ich das denn?

MFG Poempel

Hat er dir doch gerade erklärt. Eieieiei... :roll:

Poempel 12. Jan 2006 13:04

Re: Sudoku
 
Und jetzt soll ich das alles hier eintippen???

Oxmyx 12. Jan 2006 13:05

Re: Sudoku
 
Wenn es was kurzes ist, ja. Wenn es was langes ist, dann hängst du die PAS-Datei als Anhang an einen Beitrag an.

Poempel 12. Jan 2006 13:06

Re: Sudoku
 
Delphi-Quellcode:

unit msudoku;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;

type
  summentyp = record
    spalte, zeile, quadrant : byte;
  end;
  feldtyp = record
    data : array[1..9] of array[1..9] of byte;
  end;
  punkttyp = record
    x,y : byte;
  end;
  mengentyp = record
    data : array[1..9] of array[1..9] of array[1..9] of boolean;
  end;
  ausgabetyp = record
    summen : array[1..9] of summentyp;
    data : array[1..9] of array[1..9] of byte;
  end;
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit11: TEdit;
    Edit12: TEdit;
    Edit13: TEdit;
    Edit14: TEdit;
    Edit15: TEdit;
    Edit16: TEdit;
    Edit17: TEdit;
    Edit18: TEdit;
    Edit19: TEdit;
    Edit21: TEdit;
    Edit22: TEdit;
    Edit23: TEdit;
    Edit24: TEdit;
    Edit25: TEdit;
    Edit26: TEdit;
    Edit27: TEdit;
    Edit28: TEdit;
    Edit29: TEdit;
    Edit31: TEdit;
    Edit32: TEdit;
    Edit33: TEdit;
    Edit34: TEdit;
    Edit35: TEdit;
    Edit36: TEdit;
    Edit37: TEdit;
    Edit38: TEdit;
    Edit39: TEdit;
    Edit41: TEdit;
    Edit42: TEdit;
    Edit43: TEdit;
    Edit44: TEdit;
    Edit45: TEdit;
    Edit46: TEdit;
    Edit47: TEdit;
    Edit48: TEdit;
    Edit49: TEdit;
    Edit51: TEdit;
    Edit52: TEdit;
    Edit53: TEdit;
    Edit54: TEdit;
    Edit55: TEdit;
    Edit56: TEdit;
    Edit57: TEdit;
    Edit58: TEdit;
    Edit59: TEdit;
    Edit61: TEdit;
    Edit62: TEdit;
    Edit63: TEdit;
    Edit64: TEdit;
    Edit65: TEdit;
    Edit66: TEdit;
    Edit67: TEdit;
    Edit68: TEdit;
    Edit69: TEdit;
    Edit71: TEdit;
    Edit72: TEdit;
    Edit73: TEdit;
    Edit74: TEdit;
    Edit75: TEdit;
    Edit76: TEdit;
    Edit77: TEdit;
    Edit78: TEdit;
    Edit79: TEdit;
    Edit81: TEdit;
    Edit82: TEdit;
    Edit83: TEdit;
    Edit84: TEdit;
    Edit85: TEdit;
    Edit86: TEdit;
    Edit87: TEdit;
    Edit88: TEdit;
    Edit89: TEdit;
    Button1: TButton;
    Edit10: TEdit;
    Edit20: TEdit;
    Edit30: TEdit;
    Edit40: TEdit;
    Edit50: TEdit;
    Edit60: TEdit;
    Edit70: TEdit;
    Edit80: TEdit;
    Edit90: TEdit;
    Edit91: TEdit;
    Edit92: TEdit;
    Edit93: TEdit;
    Edit94: TEdit;
    Edit95: TEdit;
    Edit96: TEdit;
    Edit97: TEdit;
    Edit98: TEdit;
    Edit99: TEdit;
    Edit100: TEdit;
    Edit101: TEdit;
    Edit102: TEdit;
    Edit103: TEdit;
    Edit104: TEdit;
    Edit105: TEdit;
    Edit106: TEdit;
    Edit107: TEdit;
    Edit108: TEdit;
    procedure Button1Click(Sender: TObject);
    function loaddata: feldtyp;
    procedure savedata(tempfeld: ausgabetyp);
    function testmengen(tempfeld: feldtyp):mengentyp;
    function SucheLoesung(feld: feldtyp):feldtyp;
    function SucheMinimum(feld: feldtyp):punkttyp;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.loaddata: feldtyp;
var tempfeld: feldtyp;
begin
  try
    tempfeld.data[1,1] := strtoint(edit1.Text);
    tempfeld.data[1,2] := strtoint(edit2.Text);
    tempfeld.data[1,3] := strtoint(edit3.Text);
    tempfeld.data[1,4] := strtoint(edit4.Text);
    tempfeld.data[1,5] := strtoint(edit5.Text);
    tempfeld.data[1,6] := strtoint(edit6.Text);
    tempfeld.data[1,7] := strtoint(edit7.Text);
    tempfeld.data[1,8] := strtoint(edit8.Text);
    tempfeld.data[1,9] := strtoint(edit9.Text);

    tempfeld.data[2,1] := strtoint(edit11.Text);
    tempfeld.data[2,2] := strtoint(edit12.Text);
    tempfeld.data[2,3] := strtoint(edit13.Text);
    tempfeld.data[2,4] := strtoint(edit14.Text);
    tempfeld.data[2,5] := strtoint(edit15.Text);
    tempfeld.data[2,6] := strtoint(edit16.Text);
    tempfeld.data[2,7] := strtoint(edit17.Text);
    tempfeld.data[2,8] := strtoint(edit18.Text);
    tempfeld.data[2,9] := strtoint(edit19.Text);

    tempfeld.data[3,1] := strtoint(edit21.Text);
    tempfeld.data[3,2] := strtoint(edit22.Text);
    tempfeld.data[3,3] := strtoint(edit23.Text);
    tempfeld.data[3,4] := strtoint(edit24.Text);
    tempfeld.data[3,5] := strtoint(edit25.Text);
    tempfeld.data[3,6] := strtoint(edit26.Text);
    tempfeld.data[3,7] := strtoint(edit27.Text);
    tempfeld.data[3,8] := strtoint(edit28.Text);
    tempfeld.data[3,9] := strtoint(edit29.Text);

    tempfeld.data[4,1] := strtoint(edit31.Text);
    tempfeld.data[4,2] := strtoint(edit32.Text);
    tempfeld.data[4,3] := strtoint(edit33.Text);
    tempfeld.data[4,4] := strtoint(edit34.Text);
    tempfeld.data[4,5] := strtoint(edit35.Text);
    tempfeld.data[4,6] := strtoint(edit36.Text);
    tempfeld.data[4,7] := strtoint(edit37.Text);
    tempfeld.data[4,8] := strtoint(edit38.Text);
    tempfeld.data[4,9] := strtoint(edit39.Text);

    tempfeld.data[5,1] := strtoint(edit41.Text);
    tempfeld.data[5,2] := strtoint(edit42.Text);
    tempfeld.data[5,3] := strtoint(edit43.Text);
    tempfeld.data[5,4] := strtoint(edit44.Text);
    tempfeld.data[5,5] := strtoint(edit45.Text);
    tempfeld.data[5,6] := strtoint(edit46.Text);
    tempfeld.data[5,7] := strtoint(edit47.Text);
    tempfeld.data[5,8] := strtoint(edit48.Text);
    tempfeld.data[5,9] := strtoint(edit49.Text);

    tempfeld.data[6,1] := strtoint(edit51.Text);
    tempfeld.data[6,2] := strtoint(edit52.Text);
    tempfeld.data[6,3] := strtoint(edit53.Text);
    tempfeld.data[6,4] := strtoint(edit54.Text);
    tempfeld.data[6,5] := strtoint(edit55.Text);
    tempfeld.data[6,6] := strtoint(edit56.Text);
    tempfeld.data[6,7] := strtoint(edit57.Text);
    tempfeld.data[6,8] := strtoint(edit58.Text);
    tempfeld.data[6,9] := strtoint(edit59.Text);

    tempfeld.data[7,1] := strtoint(edit61.Text);
    tempfeld.data[7,2] := strtoint(edit62.Text);
    tempfeld.data[7,3] := strtoint(edit63.Text);
    tempfeld.data[7,4] := strtoint(edit64.Text);
    tempfeld.data[7,5] := strtoint(edit65.Text);
    tempfeld.data[7,6] := strtoint(edit66.Text);
    tempfeld.data[7,7] := strtoint(edit67.Text);
    tempfeld.data[7,8] := strtoint(edit68.Text);
    tempfeld.data[7,9] := strtoint(edit69.Text);

    tempfeld.data[8,1] := strtoint(edit71.Text);
    tempfeld.data[8,2] := strtoint(edit72.Text);
    tempfeld.data[8,3] := strtoint(edit73.Text);
    tempfeld.data[8,4] := strtoint(edit74.Text);
    tempfeld.data[8,5] := strtoint(edit75.Text);
    tempfeld.data[8,6] := strtoint(edit76.Text);
    tempfeld.data[8,7] := strtoint(edit77.Text);
    tempfeld.data[8,8] := strtoint(edit78.Text);
    tempfeld.data[8,9] := strtoint(edit79.Text);

    tempfeld.data[9,1] := strtoint(edit81.Text);
    tempfeld.data[9,2] := strtoint(edit82.Text);
    tempfeld.data[9,3] := strtoint(edit83.Text);
    tempfeld.data[9,4] := strtoint(edit84.Text);
    tempfeld.data[9,5] := strtoint(edit85.Text);
    tempfeld.data[9,6] := strtoint(edit86.Text);
    tempfeld.data[9,7] := strtoint(edit87.Text);
    tempfeld.data[9,8] := strtoint(edit88.Text);
    tempfeld.data[9,9] := strtoint(edit89.Text);
  except
    showmessage('fehlerhafte Eingabe');
  end;
  result := tempfeld;
end;

procedure TForm1.savedata(tempfeld: ausgabetyp);
begin
  edit1.Text := inttostr(tempfeld.data[1,1]);
  edit2.Text := inttostr(tempfeld.data[1,2]);
  edit3.Text := inttostr(tempfeld.data[1,3]);
  edit4.Text := inttostr(tempfeld.data[1,4]);
  edit5.Text := inttostr(tempfeld.data[1,5]);
  edit6.Text := inttostr(tempfeld.data[1,6]);
  edit7.Text := inttostr(tempfeld.data[1,7]);
  edit8.Text := inttostr(tempfeld.data[1,8]);
  edit9.Text := inttostr(tempfeld.data[1,9]);

  edit11.Text := inttostr(tempfeld.data[2,1]);
  edit12.Text := inttostr(tempfeld.data[2,2]);
  edit13.Text := inttostr(tempfeld.data[2,3]);
  edit14.Text := inttostr(tempfeld.data[2,4]);
  edit15.Text := inttostr(tempfeld.data[2,5]);
  edit16.Text := inttostr(tempfeld.data[2,6]);
  edit17.Text := inttostr(tempfeld.data[2,7]);
  edit18.Text := inttostr(tempfeld.data[2,8]);
  edit19.Text := inttostr(tempfeld.data[2,9]);

  edit21.Text := inttostr(tempfeld.data[3,1]);
  edit22.Text := inttostr(tempfeld.data[3,2]);
  edit23.Text := inttostr(tempfeld.data[3,3]);
  edit24.Text := inttostr(tempfeld.data[3,4]);
  edit25.Text := inttostr(tempfeld.data[3,5]);
  edit26.Text := inttostr(tempfeld.data[3,6]);
  edit27.Text := inttostr(tempfeld.data[3,7]);
  edit28.Text := inttostr(tempfeld.data[3,8]);
  edit29.Text := inttostr(tempfeld.data[3,9]);

  edit31.Text := inttostr(tempfeld.data[4,1]);
  edit32.Text := inttostr(tempfeld.data[4,2]);
  edit33.Text := inttostr(tempfeld.data[4,3]);
  edit34.Text := inttostr(tempfeld.data[4,4]);
  edit35.Text := inttostr(tempfeld.data[4,5]);
  edit36.Text := inttostr(tempfeld.data[4,6]);
  edit37.Text := inttostr(tempfeld.data[4,7]);
  edit38.Text := inttostr(tempfeld.data[4,8]);
  edit39.Text := inttostr(tempfeld.data[4,9]);

  edit41.Text := inttostr(tempfeld.data[5,1]);
  edit42.Text := inttostr(tempfeld.data[5,2]);
  edit43.Text := inttostr(tempfeld.data[5,3]);
  edit44.Text := inttostr(tempfeld.data[5,4]);
  edit45.Text := inttostr(tempfeld.data[5,5]);
  edit46.Text := inttostr(tempfeld.data[5,6]);
  edit47.Text := inttostr(tempfeld.data[5,7]);
  edit48.Text := inttostr(tempfeld.data[5,8]);
  edit49.Text := inttostr(tempfeld.data[5,9]);

  edit51.Text := inttostr(tempfeld.data[6,1]);
  edit52.Text := inttostr(tempfeld.data[6,2]);
  edit53.Text := inttostr(tempfeld.data[6,3]);
  edit54.Text := inttostr(tempfeld.data[6,4]);
  edit55.Text := inttostr(tempfeld.data[6,5]);
  edit56.Text := inttostr(tempfeld.data[6,6]);
  edit57.Text := inttostr(tempfeld.data[6,7]);
  edit58.Text := inttostr(tempfeld.data[6,8]);
  edit59.Text := inttostr(tempfeld.data[6,9]);

  edit61.Text := inttostr(tempfeld.data[7,1]);
  edit62.Text := inttostr(tempfeld.data[7,2]);
  edit63.Text := inttostr(tempfeld.data[7,3]);
  edit64.Text := inttostr(tempfeld.data[7,4]);
  edit65.Text := inttostr(tempfeld.data[7,5]);
  edit66.Text := inttostr(tempfeld.data[7,6]);
  edit67.Text := inttostr(tempfeld.data[7,7]);
  edit68.Text := inttostr(tempfeld.data[7,8]);
  edit69.Text := inttostr(tempfeld.data[7,9]);

  edit71.Text := inttostr(tempfeld.data[8,1]);
  edit72.Text := inttostr(tempfeld.data[8,2]);
  edit73.Text := inttostr(tempfeld.data[8,3]);
  edit74.Text := inttostr(tempfeld.data[8,4]);
  edit75.Text := inttostr(tempfeld.data[8,5]);
  edit76.Text := inttostr(tempfeld.data[8,6]);
  edit77.Text := inttostr(tempfeld.data[8,7]);
  edit78.Text := inttostr(tempfeld.data[8,8]);
  edit79.Text := inttostr(tempfeld.data[8,9]);

  edit81.Text := inttostr(tempfeld.data[9,1]);
  edit82.Text := inttostr(tempfeld.data[9,2]);
  edit83.Text := inttostr(tempfeld.data[9,3]);
  edit84.Text := inttostr(tempfeld.data[9,4]);
  edit85.Text := inttostr(tempfeld.data[9,5]);
  edit86.Text := inttostr(tempfeld.data[9,6]);
  edit87.Text := inttostr(tempfeld.data[9,7]);
  edit88.Text := inttostr(tempfeld.data[9,8]);
  edit89.Text := inttostr(tempfeld.data[9,9]);

  edit10.Text := inttostr(tempfeld.summen[1].zeile);
  edit20.Text := inttostr(tempfeld.summen[2].zeile);
  edit30.Text := inttostr(tempfeld.summen[3].zeile);
  edit40.Text := inttostr(tempfeld.summen[4].zeile);
  edit50.Text := inttostr(tempfeld.summen[5].zeile);
  edit60.Text := inttostr(tempfeld.summen[6].zeile);
  edit70.Text := inttostr(tempfeld.summen[7].zeile);
  edit80.Text := inttostr(tempfeld.summen[8].zeile);
  edit90.Text := inttostr(tempfeld.summen[9].zeile);

  edit91.Text := inttostr(tempfeld.summen[1].spalte);
  edit92.Text := inttostr(tempfeld.summen[2].spalte);
  edit93.Text := inttostr(tempfeld.summen[3].spalte);
  edit94.Text := inttostr(tempfeld.summen[4].spalte);
  edit95.Text := inttostr(tempfeld.summen[5].spalte);
  edit96.Text := inttostr(tempfeld.summen[6].spalte);
  edit97.Text := inttostr(tempfeld.summen[7].spalte);
  edit98.Text := inttostr(tempfeld.summen[8].spalte);
  edit99.Text := inttostr(tempfeld.summen[9].spalte);

  edit100.Text := inttostr(tempfeld.summen[1].quadrant);
  edit101.Text := inttostr(tempfeld.summen[2].quadrant);
  edit102.Text := inttostr(tempfeld.summen[3].quadrant);
  edit103.Text := inttostr(tempfeld.summen[4].quadrant);
  edit104.Text := inttostr(tempfeld.summen[5].quadrant);
  edit105.Text := inttostr(tempfeld.summen[6].quadrant);
  edit106.Text := inttostr(tempfeld.summen[7].quadrant);
  edit107.Text := inttostr(tempfeld.summen[8].quadrant);
  edit108.Text := inttostr(tempfeld.summen[9].quadrant);
end;

function TForm1.testmengen(tempfeld: feldtyp):mengentyp;
var i, c, i2, c2, tempbyte : byte;
  mengen : mengentyp;
  summen : summentyp;
begin
  for i := 1 to 9 do for c := 1 to 9 do for tempbyte := 1 to 9 do mengen.data[i,c,tempbyte] := true;
  for i := 1 to 9 do for c := 1 to 9 do
  begin
    if tempfeld.data[i,c] > 0 then
    begin
      for tempbyte := 1 to 9 do mengen.data[i,tempbyte,tempfeld.data[i,c]] := false;
      for tempbyte := 1 to 9 do mengen.data[tempbyte,c,tempfeld.data[i,c]] := false;
      if i in[1..3] then
      begin
        if c in[1..3] then for i2 := 1 to 3 do for c2 := 1 to 3 do mengen.data[i2,c2,tempfeld.data[i,c]] := false
        else if c in[4..6] then for i2 := 1 to 3 do for c2 := 4 to 6 do mengen.data[i2,c2,tempfeld.data[i,c]] := false
        else if c in[7..9] then for i2 := 1 to 3 do for c2 := 7 to 9 do mengen.data[i2,c2,tempfeld.data[i,c]] := false;
      end else if i in[4..6] then
      begin
        if c in[1..3] then for i2 := 4 to 6 do for c2 := 1 to 3 do mengen.data[i2,c2,tempfeld.data[i,c]] := false
        else if c in[4..6] then for i2 := 4 to 6 do for c2 := 4 to 6 do mengen.data[i2,c2,tempfeld.data[i,c]] := false
        else if c in[7..9] then for i2 := 4 to 6 do for c2 := 7 to 9 do mengen.data[i2,c2,tempfeld.data[i,c]] := false;
      end else if i in[7..9] then
      begin
        if c in[1..3] then for i2 := 7 to 9 do for c2 := 1 to 3 do mengen.data[i2,c2,tempfeld.data[i,c]] := false
        else if c in[4..6] then for i2 := 7 to 9 do for c2 := 4 to 6 do mengen.data[i2,c2,tempfeld.data[i,c]] := false
        else if c in[7..9] then for i2 := 7 to 9 do for c2 := 7 to 9 do mengen.data[i2,c2,tempfeld.data[i,c]] := false;
      end;
    end;
  end;
  for i := 1 to 9 do
  begin
    tempbyte := 0;
    for c := 1 to 9 do
    begin
      tempbyte := tempbyte + tempfeld.data[i,c];
    end;
    summen[i].zeile := tempbyte;
  end;
  for i := 1 to 9 do
  begin
    tempbyte := 0;
    for c := 1 to 9 do
    begin
      tempbyte := tempbyte + tempfeld.data[c,i];
    end;
    summen[i].spalte := tempbyte;
  end;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c,i];
    end;
  end;
  summen[1].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c,i+3];
    end;
  end;
  summen[2].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c,i+6];
    end;
  end;
  summen[3].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c+3,i];
    end;
  end;
  summen[4].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c+3,i+3];
    end;
  end;
  summen[5].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c+3,i+6];
    end;
  end;
  summen[6].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c+6,i];
    end;
  end;
  summen[7].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c+6,i+3];
    end;
  end;
  summen[8].quadrant := tempbyte;
  tempbyte := 0;
  for c := 1 to 3 do
  begin
    for i := 1 to 3 do
    begin
      tempbyte := tempbyte + tempfeld.data[c+6,i+6];
    end;
  end;
  summen[9].quadrant := tempbyte;
end;

function SucheMinimum(feld: feldtyp):punkttyp;
var i, c : Byte;
begin
  for i := 1 to 9 do for c := 1 to 9 do
  begin
  end;
end;

function TForm1.SucheLoesung(feld: feldtyp):feldtyp;
var i, c : Byte;
begin
  testmengen;
  for i := 1 to 9 do for c := 1 to 9 do
  begin

  end;
  result := feld;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  loaddata;
  originalfeld := SucheLoesung(originalfeld);
  savedata;
end;

end.


Ok so?

Khabarakh 12. Jan 2006 13:17

Re: Sudoku
 
:shock: Von Arrays oder einem simplen Stringgrid hat dein Bruder aber noch nichts gehört, oder?
Was sollen wir jetzt mit dem Quelltext machen? Für dich fertigschreiben?
Wie Stanlay schon gesagt hat, wenn du ein konkretes Problem hast, helfen wir dir gerne weiter.

3_of_8 12. Jan 2006 13:21

Re: Sudoku
 
Und nebenbei: Typen beginnen konventionsgemäß immer mit einem T, außer bei Exceptions, die mit E und Interfaces, die mit I beginnen.

hanselmansel 12. Jan 2006 16:42

Re: Sudoku
 
Hallo Poempel,
  1. Den Tipp von Kharhab...(ich kann mir diesen Namen einfach nicht merken!) solltet ihr euch wirklich zu Herzen nehmen. Dadurch wird der Code viel übersichtlicher.
  2. Ich habe nicht den gesamten Quelltext durchgelesen, aber so wie die Variablen benannt sind, scheint ihr ja schon mit Mengen zu arbeiten.
  3. Jetzt solltest du uns genau sagen wo es kracht ( / nicht funktioniert), denn so viel Code fehlersuchend durchzulesen wäre eine mörderische Arbeit.

MfG,

hanselmansel

Poempel 13. Jan 2006 13:42

Re: Sudoku
 
Hallo!

Ja, also ich glaube mein größtes Problem ist, dass ich nicht weiß was das alles für Befehle sind!
Naja, ich wede mir das alles mal etwas genauer angucken!

MFG Poempel

Der_Unwissende 13. Jan 2006 18:58

Re: Sudoku
 
Zitat:

Zitat von Oxmyx
Wenn es was kurzes ist, ja. Wenn es was langes ist, dann hängst du die PAS-Datei als Anhang an einen Beitrag an.

Und nur mal nebenbei, das war etwas, was man als lang bezeichnen könnte

Ach und natürlich macht Sudoku nur Spaß wenn man selber denkt :wink:

Khabarakh 13. Jan 2006 19:03

Re: Sudoku
 
Zitat:

Zitat von Poempel
Hallo!

Ja, also ich glaube mein größtes Problem ist, dass ich nicht weiß was das alles für Befehle sind!

Cursor auf den Befehl -> F1 :wink:

Nils_13 13. Jan 2006 19:06

Re: Sudoku
 
Ähm, wozu braucht man 108 Edits ?


F1 bringt nicht so viel, man muss immer die Zusammenhänge sehen.

Zusammenfassung:
Er will wahrscheinlich, dass wir ihm den Code grob oder in allen Einzelheiten erklären, weil er es nicht programmiert hat, sein Bruder weg ist und sein Bruder es ihm deswegen nicht erklären kann.

Schaedel 13. Jan 2006 19:58

Re: Sudoku
 
Findcomponent sollte helfen ... und dann For- schleife ;)
Macht den Quelltext um 75% kürzer.
Also wenn du den Quelltext aufmotzen willst schau mal in der Hilfe unter Findcomponent und bau dann eine For schleife dazu

3_of_8 13. Jan 2006 20:00

Re: Sudoku
 
Es gäbe auch noch die Möglichkeit, ein array of TEdit zu nehmen, und in OnFormCreate die einzelnen TEdits zu instantiieren.

Schaedel 13. Jan 2006 20:05

Re: Sudoku
 
Sudoku- Wikipedia

Falls wer Energie investieren möchte ... ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz