3
Would it have any function to shuffle in Delphi to shuffle a string
.
- String Ex := 'wooden house';
- Return ex := 'medr ci saedaaa';
3
Would it have any function to shuffle in Delphi to shuffle a string
.
3
Posting not to go unanswered as suggested by the author of the question.
Source: Jefferson Rudolf (users/34982)
function EmbaralharString(const aString: string): string;
var
i: integer;
vPosicao: integer;
vLista: TStrings;
begin
Randomize;
vLista := TStringList.Create;
for i := 1 to aString.Length do
vLista.Add(aString[i]);
for i := 1 to aString.Length do
begin
vPosicao := Random(vLista.Count);
Result := Result + vLista.Strings[vPosicao];
vLista.Delete(vPosicao);
end;
FreeAndNil(vLista);
end;
Very simple, first it unmounts the string in and creates a list of "char", then randomly takes each "char" and mounts a new string.
Browser other questions tagged delphi delphi-7 delphi-10
You are not signed in. Login or sign up in order to post.
Give a look if it helps https://www.clubedohardware.com.br/forums/topic/567952-scramblerletters/
– Jefferson Rudolf
That’s right. To not go unanswered can I put the code with the answer? or you put... will the site go off the air...
– Edu Mendonça
If you’ve solved it you can put the code to help people.
– Jefferson Rudolf