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,7ba49aac4e73460 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.222.71 with SMTP id qk7mr3020917pbc.1.1328853386639; Thu, 09 Feb 2012 21:56:26 -0800 (PST) Path: wr5ni7569pbc.0!nntp.google.com!news1.google.com!news2.google.com!news.glorb.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "Alex" Newsgroups: comp.lang.ada Subject: Re: Need Help On Ada95 Problem Date: Fri, 10 Feb 2012 05:45:22 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <553ceec3-ec34-41de-9723-0dc342379cfe@vv9g2000pbc.googlegroups.com> <4ea6309f-cf07-44f6-8c56-5189a0081dcc@g27g2000yqa.googlegroups.com> Mime-Version: 1.0 Injection-Date: Fri, 10 Feb 2012 05:45:22 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="idyNQtORD/zz+8SMt6pqMA"; logging-data="23914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tso7p3CWvGtPiOcQhVk0Bn7Tghq8aNwY=" User-Agent: XanaNews/1.19.1.320 Cancel-Lock: sha1:2m+qUO1TmqbinyyDwfoU+z3iIAE= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: 2012-02-10T05:45:22+00:00 List-Id: Oh, I see how you're confused. Once you get the value of each digit in the PIN, though, it doesn't matter that the 3-4-5 corresponding to V-A-L isn't in ASCII order. . . it's still just a direct index-based lookup (just off-by-one because Ada Strings are indexed starting at 1 rather than 0). Shark8 wrote: > On Feb 9, 7:36�pm, BrianG wrote: > > On 02/08/2012 09:01 PM, Shark8 wrote: > > > > > > > > > > > > > > > > > > > > > On Feb 8, 7:03 pm, Will �wrote: > > >> I am new to Ada and need help on an exercise for school. �Can > > anyone >> help. �The problem is as follows ( you can skip all the > > build up >> background A Christmas Story references): > > > > >> Problem 1: Secret Decoder Ring > > ... > > >> � � � number wheel -> � � �0 �1 �2 �3 �4 �5 �6 �7 �8 �9 > > >> � � � letter wheel -> � � �U �R �O �V �A �L �T �I �N �E > > > > >> So, for example, Randy encrypts the PIN 9537 as ELVI. > > > > >> Complete the function Encrypt(PIN) that takes a 4-digit PIN (as a > > >> string) and returns the corresponding 4-letter code (also as a > > >> string). > > > > >> Note: It would be possible to convert digits to letters using a > > giant >> IF statement, but don't do this. Instead, the letter wheel > > is given to >> you as a string, so use each digit to read the > > appropriate letter from >> the string. > > > > > Alright this is actually a simple problem; there are several ways > > > to go about this, > > > but let's play to Ada's strengths and use types. > > > > ... > > > Reading the problem the note says: > > > It would be possible to convert digits to letters using a giant > > > IF statement, but don't do this. Instead, the letter wheel is > > > given to you as a string, so use each digit to read the > > > appropriate letter from the string. > > > > > Meaning that they're hinting strongly that you use the CASE > > > statement. > > > > I don't see why this would require either an if or a case. > > > > -- > > --- > > BrianG > > 000 > > @[Google's email domain] > > .com > > Well, you COULD use Ada's Maps; but that's just going to do the same > thing: you still have to define the mapping. > You can't just index into Character (via 'POS, 'VAL and index- > manipulation) because the mapping isn't sequential; > or even partly-sequential in the ASCII codes. > > See the (3,4,5) association with (V,A,L) and (6,7,8) with (T,I,N).