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

  1. Path: sparky!uunet!olivea!charnel!rat!usc!sdd.hp.com!scd.hp.com!hpscdm!cupnews0.cup.hp.com!news1.boi.hp.com!hp-pcd!hpcvra!rnews!hpcvbbs!akcs.joehorn
  2. From: akcs.joehorn@hpcvbbs.cv.hp.com (Joseph K. Horn)
  3. Newsgroups: comp.sys.hp48
  4. Subject: Cliff Stern's Little Challenges
  5. Message-ID: <2af8cafe.2066comp.sys.hp48@hpcvbbs.cv.hp.com>
  6. Date: 5 Nov 92 07:40:02 GMT
  7. Lines: 63
  8.  
  9. *** RECREATIONAL PROGRAMMING DEPARTMENT ***
  10.  
  11. All you old-timers: remember Cliff Stern?  He was very active in the
  12. PPC heydays, especially in the field of HP-41 "m-code" programming.
  13.  
  14. Well, he has an HP 48 now, but no computer, hence no access to the net
  15. or to System RPL or ML.  But he gets a kick out of optimizing User RPL
  16. programs, and we often swap fun challenges over the phone.
  17.  
  18. You'll enjoy Cliff Stern's latest challenges.  Use 100% normal User
  19. RPL, with no SYSEVAL's or monkey business!  These are really tests of
  20. your knowledge of HP-documented User RPL, not of bizarre undocumented
  21. HP 48 anomalies.  Of course, assume default mode settings, etc.
  22.  
  23. ----
  24.  
  25. (1a) Write a program that takes as input a real number on level 1, and
  26.      then drops it if it's a zero, or leaves it alone if it's not zero.
  27.  
  28. (1b) Using IF-THEN-END, do the same program in 20 bytes (including the
  29.      << >> program delimiters; use the BYTES command to check).
  30.  
  31. (1c) Now do it in 15 bytes.  (Hint: don't use IF-THEN-END).
  32.  
  33. ----
  34.  
  35. (2a) Write a program that takes as input a list of two or more reals
  36.      on level 1, and replaces it with the sum of its elements.
  37.  
  38. (2b) Now do the same program in 25 bytes (including << >> as always).
  39.  
  40. (2c) If we can assume that all the elements are positive, do the same
  41.      program in 17.5 bytes.
  42.  
  43. ----
  44.  
  45. (3a) Assume that there is at least one object on the stack.  Write a
  46.      program that clears the stack of everything *except* for the
  47.      object in level 1, which is left alone.  (Can be thought of as 1
  48.      KEEP).  Remember: no SYSEVALs or library function calls!
  49.  
  50. (3b) Now do it in 17.5 bytes.
  51.  
  52. ----
  53.  
  54. (4)  Place WHILE UNTIL END on level 1, just like that (without any <<
  55.      >> program or { } list delimiters around it).  Remember: no
  56.      SYSEVALs or library function calls!
  57.  
  58. ----
  59.  
  60. (5)  Write a program that takes as input an integer 1 through 26, and
  61.      creates that many (and no more) *local* variables 'a', 'b', 'c',
  62.      etc., and then HALTs, leaving the local variables active.  Their
  63.      contents do not matter.  Example: an input of 5 would create 'a',
  64.      'b', 'c', 'd', and 'e', and nothing else.
  65.  
  66. ----
  67.  
  68. Problems 1 through 4 are non-obvious but are not difficult.
  69. Problem 5 is more difficult but very possible.  My first attempt
  70. yielded a 115.5-byte solution; I'm sure there's a shorter way.
  71.  
  72. Have fun!  -Joe Horn-
  73.