home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!destroyer!cs.ubc.ca!unixg.ubc.ca!ochealth
- From: ochealth@unixg.ubc.ca (ochealth)
- Newsgroups: comp.sys.hp48
- Subject: Re: Cliff Stern's Little Challenges
- Date: 6 Nov 1992 21:55:33 GMT
- Organization: University of British Columbia, Vancouver, B.C., Canada
- Lines: 43
- Message-ID: <1depklINNnpo@iskut.ucs.ubc.ca>
- References: <Bx9D8A.3H0@iat.holonet.net>
- NNTP-Posting-Host: unixg.ubc.ca
-
- In article <Bx9D8A.3H0@iat.holonet.net> brianw@iat.holonet.net (Brian Walsh) writes:
- :In message <2af8cafe.2066comp.sys.hp48@hpcvbbs.cv.hp.com> Joe Horn writes:
- :
- :> (5) Write a program that takes as input an integer 1 through 26, and
- :> creates that many (and no more) *local* variables 'a', 'b', 'c',
- :> etc., and then HALTs, leaving the local variables active. Their
- :> contents do not matter. Example: an input of 5 would create 'a',
- :> 'b', 'c', 'd', and 'e', and nothing else.
- :
- :Here are two solutions:
- :%%HP: T(3)A(D)F(.);
- :\<< 2 * 2 +
- :"\-> a b c d e f g h i j k l m n o p q r s t u v w x y z"
- :1 ROT SUB "\<<HALT" + STR\->
- :\>>
- :100.5 bytes
- :
- :%%HP: T(3)A(D)F(.);
- :\<< "\->" 1 ROT
- : FOR i " " + i 96 + CHR +
- : NEXT "\<<HALT" + STR\->
- :\>>
- :76.5 bytes
- :
- :Both use the technique of building a program as a string and then using
- :STR-> to evaluate the program. The second is quite small but takes more
- :execution time.
-
- But the challenge said the program had to take a single integer as input,
- and these programs assume that there are enough arguments on the stack.
- At least that's how I read the challenge.
-
- :
- :-- Brian Walsh
- : brianw@holonet.net -Just say no to taglines-
- :
-
-
- --
- ______________________________________________________________________________
- jpm: ochealth@unixg.ubc.ca
- Happily using OS/2 2.0 because MS Windows isNT ___
- Insert VapourFeature ^^^
-