Fandt og rettede dette lidt til (
http://www.delphi3000.com/articles/article_3407.asp?SK=). Skal holdes op mod en eller anden stavekontrol
procedure TfrmMain.Anagramize(aList: TStrings; const aInput: string);
// Internal Recursive routine
procedure RecursePerm(const aStrA, aStrB : string; const aLength : integer; aStrings : TStrings);
var
i: integer;
A,B: string;
begin
// Is built up word the length we require ?
if length(aStrA) = aLength then
begin
// Check if not a duplicate and search dictionary for valid word check.
if (aStrings.IndexOf(aStrA) = -1) { and MsWordApp.CheckSpelling(StrA) } then
aStrings.Add(aStrA);
end;
for i := 1 to length(aStrB) do
begin
// Recursively build all possible permutations of word
A := aStrB;
B := aStrA + A[i];
delete(A,i,1);
RecursePerm(B,A,aLength,aStrings);
end;
end;
begin
aList.BeginUpdate;
try
aList.Clear;
RecursePerm('',AnsiLowerCase(aInput),length(aInput),aList);
finally
aList.EndUpdate;
end;
end;