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.204.150.90 with SMTP id x26mr140295bkv.6.1331116795992; Wed, 07 Mar 2012 02:39:55 -0800 (PST) Path: t13ni109552bkb.0!nntp.google.com!news1.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.ecp.fr!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Can I convert a string of letters into an array? Date: Wed, 07 Mar 2012 11:39:52 +0100 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <878vjcheyv.fsf@adaheads.sparre-andersen.dk> References: <9891847.4305.1330998375979.JavaMail.geo-discussion-forums@vbai14> <9204342.4227.1331003586295.JavaMail.geo-discussion-forums@vbux23> NNTP-Posting-Host: 95.209.238.149.bredband.3.dk Mime-Version: 1.0 X-Trace: munin.nbi.dk 1331116794 31124 95.209.238.149 (7 Mar 2012 10:39:54 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 7 Mar 2012 10:39:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:4NcWjX4J5Li6VqSMh2mBgCYmVIE= Content-Type: text/plain; charset=us-ascii Date: 2012-03-07T11:39:52+01:00 List-Id: Dennis Lee Bieber wrote: > That's all? Given the specifications you don't even need to > "rearrange" the contents. All you need is the total length, and a pass > over the string to count how many "B"s appear in it. That gives you > the information of how many "G"s are in it (since the spec says you > don't have to worry about any other characters). Given m-B, n-G, a > moderately simple loop can be used to emit alternating BG pairs until > the shorter one has expired, then just emit enough of the remaining > letter to fill out the required length. Why not just use Ada.Strings.Fixed.Count and Ada.Strings.Fixed."*". Jacob -- "Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves."