There is a code that List.Box through all possible combinations of line elements and displays them in List.Box :
procedure TForm1.Button1Click(Sender: TObject); var m: integer; procedure GenStr(S0, S1: string); var i: integer; begin if Length(S0) = m then ListBox1.Items.Add(S0) else for i := 1 to Length(S1) do GenStr(S0+S1[i], copy(S1,1,i-1) + copy(S1,i+1,Length(S1))); end; begin m := 3; GenStr('','123'); end; end. After the execution I get the result: 123 , 132 , 213 , 231 , 312 , 321 , which, regarding the execution of my task, is correct.
But my task is to find such combinations in the elements of the array, and not in the string. Ie, for example execution:
a[0]:=1; a[1]:=2; a[2]:=3; GenStr('',a[0],a[1],a[2]); would give me the same result. How can this be implemented?
