home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.hp48
- Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!iat.holonet.net!brianw
- From: brianw@iat.holonet.net (Brian Walsh)
- Subject: Re: Cliff Stern's Little Challenges
- Message-ID: <BxDvyH.G6A@iat.holonet.net>
- Organization: HoloNet (BBS: 510-704-1058)
- References: <1depklINNnpo@iskut.ucs.ubc.ca>
- Date: Sun, 8 Nov 1992 06:13:27 GMT
- Lines: 31
-
- ochealth@unixg.ubc.ca (ochealth) writes:
- : 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.
- (stuff deleted)
- : :%%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.
-
- OK, the second routine works fine with a small modification:
- insert 0 SWAP between the `FOR i' and the `" "' which initializes each
- local variable to 0.
-
- -- Brian Walsh
- brianw@holonet.net
-