home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / hp48 / 5596 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.9 KB

  1. Path: sparky!uunet!destroyer!cs.ubc.ca!unixg.ubc.ca!ochealth
  2. From: ochealth@unixg.ubc.ca (ochealth)
  3. Newsgroups: comp.sys.hp48
  4. Subject: Re: Cliff Stern's Little Challenges
  5. Date: 6 Nov 1992 21:55:33 GMT
  6. Organization: University of British Columbia, Vancouver, B.C., Canada
  7. Lines: 43
  8. Message-ID: <1depklINNnpo@iskut.ucs.ubc.ca>
  9. References: <Bx9D8A.3H0@iat.holonet.net>
  10. NNTP-Posting-Host: unixg.ubc.ca
  11.  
  12. In article <Bx9D8A.3H0@iat.holonet.net> brianw@iat.holonet.net (Brian Walsh) writes:
  13. :In message <2af8cafe.2066comp.sys.hp48@hpcvbbs.cv.hp.com> Joe Horn writes:
  14. :> (5)  Write a program that takes as input an integer 1 through 26, and
  15. :>      creates that many (and no more) *local* variables 'a', 'b', 'c',
  16. :>      etc., and then HALTs, leaving the local variables active.  Their
  17. :>      contents do not matter.  Example: an input of 5 would create 'a',
  18. :>      'b', 'c', 'd', and 'e', and nothing else.
  19. :Here are two solutions:
  20. :%%HP: T(3)A(D)F(.);
  21. :\<< 2 * 2 +
  22. :"\-> 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"
  23. :1 ROT SUB "\<<HALT" + STR\->
  24. :\>>
  25. :100.5 bytes
  26. :%%HP: T(3)A(D)F(.);
  27. :\<< "\->" 1 ROT
  28. :  FOR i " " + i 96 + CHR +
  29. :  NEXT "\<<HALT" + STR\->
  30. :\>>
  31. :76.5 bytes
  32. :Both use the technique of building a program as a string and then using 
  33. :STR-> to evaluate the program.  The second is quite small but takes more
  34. :execution time.
  35.  
  36. But the challenge said the program had to take a single integer as input,
  37. and these programs assume that there are enough arguments on the stack.
  38. At least that's how I read the challenge.
  39.  
  40. :-- Brian Walsh
  41. :   brianw@holonet.net           -Just say no to taglines-
  42. :
  43.  
  44.  
  45. -- 
  46. ______________________________________________________________________________
  47. jpm: ochealth@unixg.ubc.ca         
  48.                             Happily using OS/2 2.0 because MS Windows isNT ___
  49.                                                       Insert VapourFeature ^^^
  50.