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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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.213.68 with SMTP id nq4mr2730469pbc.2.1328840893291; Thu, 09 Feb 2012 18:28:13 -0800 (PST) Path: wr5ni7031pbc.0!nntp.google.com!news1.google.com!postnews.google.com!g27g2000yqa.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Need Help On Ada95 Problem Date: Thu, 9 Feb 2012 18:22:33 -0800 (PST) Organization: http://groups.google.com Message-ID: <4ea6309f-cf07-44f6-8c56-5189a0081dcc@g27g2000yqa.googlegroups.com> References: <553ceec3-ec34-41de-9723-0dc342379cfe@vv9g2000pbc.googlegroups.com> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 X-Trace: posting.google.com 1328840893 9051 127.0.0.1 (10 Feb 2012 02:28:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 10 Feb 2012 02:28:13 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g27g2000yqa.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-02-09T18:22:33-08:00 List-Id: On Feb 9, 7:36=A0pm, BrianG wrote: > On 02/08/2012 09:01 PM, Shark8 wrote: > > > > > > > > > > > On Feb 8, 7:03 pm, Will =A0wrote: > >> I am new to Ada and need help on an exercise for school. =A0Can anyone > >> help. =A0The problem is as follows ( you can skip all the build up > >> background A Christmas Story references): > > >> Problem 1: Secret Decoder Ring > ... > >> =A0 =A0 =A0 number wheel -> =A0 =A0 =A00 =A01 =A02 =A03 =A04 =A05 =A06= =A07 =A08 =A09 > >> =A0 =A0 =A0 letter wheel -> =A0 =A0 =A0U =A0R =A0O =A0V =A0A =A0L =A0T= =A0I =A0N =A0E > > >> 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).