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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!feeder.eternal-september.org!news.swapon.de!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to shuffle/jumble letters of a given word? Date: Mon, 29 Jun 2015 10:13:23 +0200 Organization: cbb software GmbH Message-ID: <1oqptnzfvfrwi$.3rezbni7b1lm$.dlg@40tude.net> References: <24d183ce-77b6-4fe1-a95e-0ff5ef72c7bd@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: enOx0b+nfqkc2k+TNpOejg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:26522 Date: 2015-06-29T10:13:23+02:00 List-Id: On Mon, 29 Jun 2015 09:05:50 +0100, Simon Wright wrote: > "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)); It should be non-repeating random numbers in this case, provided "shuffling" meant permutation. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de