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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,612990d6f00ea42 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.74.201 with SMTP id w9mr20769150pbv.0.1331022708956; Tue, 06 Mar 2012 00:31:48 -0800 (PST) Path: h9ni45181pbe.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Can I convert a string of letters into an array? Date: Tue, 6 Mar 2012 00:29:58 -0800 (PST) Organization: http://groups.google.com Message-ID: <4063450.2061.1331022598993.JavaMail.geo-discussion-forums@yncc26> References: <9891847.4305.1330998375979.JavaMail.geo-discussion-forums@vbai14> <9204342.4227.1331003586295.JavaMail.geo-discussion-forums@vbux23> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 X-Trace: posting.google.com 1331022708 6336 127.0.0.1 (6 Mar 2012 08:31:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 6 Mar 2012 08:31:48 +0000 (UTC) In-Reply-To: <9204342.4227.1331003586295.JavaMail.geo-discussion-forums@vbux23> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-03-06T00:29:58-08:00 List-Id: Will wrote on comp.lang.ada: > Here is the problem, "Write a procedure that takes in a string of 'B' > and 'G' characters. The procedure should rearrange the letters into > an alternating 'B'-'G' pattern that continues until the less numerous > letter runs out. Assume the string only contains 'B's and 'G's; that > the patter you create always starts with a 'B'; and that the string > will always contain at least 1 of each letter. For example: > "BBBBGGGBG" becomes "BGBGBGBGB", and "GGBG" becomes "BGGG"." As others have said, a string is, by definition, an array of Characters, so you don't need to "convert a string of letters into an array". Your teacher should have already explained to you how to access individual elements (Characters) in an array (String), so this homework assignment should be no challenge to you. To get you started, here is a skeleton where you "just" need to fill in the blanks: function Rearrange (Input : in String) is Result : String (Input'Range); Number_Of_Bs : Natural; Number_Of_Gs : Natural; begin ... return Result; end Rearrange; I hope I didn't say too much... -- Ludovic Brenta.