Autor Beitrag
hui1991
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Do 06.12.07 20:46 
Hi,

ich schreib als erstes mal den Quellcode:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
procedure TForm1.Button1Click(Sender: TObject);
var
  x,y,z,temp,zahl1,zahl2,zahl3,zaehler: Integer;
  sList: TStrings;
  teil: String;
begin
  zaehler:=0;
  sList:=TStringlist.Create;
  try
    For x:=0 to 255 do
      FOr y:=0 to 255 do
        For z:=0 to 255 do begin
          if (x<>y) and (y<>z) and (z<>x) then begin
          zahl1:=x; zahl2:=y; zahl3:=z;
          If zahl1 < zahl2 Then begin
            temp := zahl2;
            zahl2 := zahl1;
            zahl1 := temp;
          End;

          If zahl1 < zahl3 Then begin
            temp := zahl3;
            zahl3 := zahl1;
            zahl1 := temp;
          End;

          If zahl2 < zahl3 Then begin
            temp := zahl3;
            zahl3 := zahl2;
            zahl2 := temp;
          End;
          teil:=chr(zahl1)+chr(zahl2)+chr(zahl3);
          If not (sList.IndexOf(teil)>0) then begin
            sList.Add(teil);
            inc(zaehler);
          end;

          if (zaehler div 1024)*1024=zaehler then begin
            Label1.Caption:='Status: '+inttostr(zaehler)+' von '+inttostr(x*255*255+y*255+z)+' (16777216) = '+inttostr(zaehler * 100 div (x*255*255+y*255+z))+' = ('+floattostr(zaehler / 16777216)+')';
            Application.ProcessMessages;
          end;
          end;
        end;
  finally
    sList.free;
  end;
end;


Also ich will alle Möglichkeiten von 256³ haben.
Ich will nur die Anzahl wissen von 256³, wenn man aber noch die abzieht:
Es dürfen nicht gleiche Bytes drin sein.
Es darf nicht doppelt vor kommen. z. B. 5-3-2 ist gleich wie 2-3-5 oder 3-5-2 es soll nur eines drin stehen.

Meine Frage:
Wie kann ich das so schnell wie Möglich errechnen?

Kann man sich da was errechnen, eine Formel, oder muss man das sich so wie bei mir ausrechnen lassen?
Blos ich weiß nicht wie ich das so schnell wie möglich machen soll.
Geht ja nur um die Anzahl.

Hoffe ihr könnt mir helfen.

MfG
hui1991
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 06.12.07 20:55 
Suchst du die Anzahl der Möglichkeiten, 3 aus 256 zu ziehen? Ähnlich beim Lotto? Das dürften 256*255*254 / 3! sein...

_________________
We are, we were and will not be.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 06.12.07 21:19 
Die Formel dafür ist:
ausblenden Quelltext
1:
2:
3:
     n!
-----------
(n-k)! * k!

Das ist einfach Stochastik. Steht vermutlich auch was bei wikipedia. Die Berechnung ist die selbe, wie bei den Lottozahlen. Nur sind es dort 6 aus 49 und hier sind es 3 aus 256.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 06.12.07 21:37 
Du willst alle geordneten Tripel, das geht so:
ausblenden Delphi-Quelltext
1:
2:
3:
    for x := 0 to 255 do
      for y := x+1 to 255 do
        for z := y+1 to 255 do // alle Tripel mit x<y<z

Mit der Formel von jasocul (siehe auch Binomialkoeffizient) kriegst du die Anzahl raus.
hui1991 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Fr 07.12.07 06:51 
Danke für die Antworten,

d. h. ich hab jetzt eine Zahl von 2.754.560. Hm.. trotzdem viele Möglichkeiten ^^

MfG
hui1991