From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How to shuffle/jumble letters of a given word? Date: Mon, 29 Jun 2015 09:05:50 +0100 Organization: A noiseless patient Spider Message-ID: References: <24d183ce-77b6-4fe1-a95e-0ff5ef72c7bd@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="c762050aff3a30866fa7e79999b14776"; logging-data="28640"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tFkYY9bYX0ZnPwQqJTP5rh8jqL3dluog=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:Q1R1gx0pKsK90uiDnJOxg78sO8o= sha1:GJDh1A7Y63lCaR9B3oNVMI1OQXI= Xref: news.eternal-september.org comp.lang.ada:26521 Date: 2015-06-29T09:05:50+01:00 List-Id: "Jeffrey R. Carter" writes: > On 06/28/2015 02:07 PM, Simon Wright wrote: >> >> Then, given a String, create an Elements array with each Key a new >> random number and each Ch the corresponding character in the String; >> sort it (which, since the Keys were random, is effectively a shuffle); >> and return a String formed of the Chs in their new order. > > You could also just sort the String. I don't see how this would work? Though I see I made myself less than clear. At the risk of solving even more of the OP's problem for her than I already have, Keyed : Elements (Str'Range); begin for J in Str'Range loop Keyed (J) := (Ada.Numerics.Float_Random.Random (Gen), Str (J)); end loop; Sort (Keyed);