Registriert seit: 6. Apr 2005
10.109 Beiträge
|
Re: CaseCorrection d. Permutataion / BruteForce d. 2. Dimens
29. Jun 2007, 20:53
Haarscharf daneben:
Delphi-Quellcode:
procedure VariateCase(s: string; sl: TStrings);
const
LETTERS: set of Char = ['a'..'z','A'..'Z', 'ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü'];
var
i, skip, n, len: Integer;
begin
len := 0;
for i := 1 to Length(s) do
Inc(len, Ord(s[i] in LETTERS));
sl.BeginUpdate;
sl.Clear;
for n := 0 to Pred(1 shl len) do
begin
skip := 0;
for i := 1 to len do
begin
while not (s[i + skip] in LETTERS) do
Inc(skip);
s[i + Skip] := IfThen(Odd(n shr Pred(i)), AnsiUpperCase(s[i + skip]), AnsiLowerCase(s[i + skip]))[1];
end;
sl.Add(s);
end;
sl.EndUpdate;
end;
|
|
Zitat
|