home *** CD-ROM | disk | FTP | other *** search
- 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
- From: akcs.joehorn@hpcvbbs.cv.hp.com (Joseph K. Horn)
- Newsgroups: comp.sys.hp48
- Subject: Cliff Stern's Little Challenges
- Message-ID: <2af8cafe.2066comp.sys.hp48@hpcvbbs.cv.hp.com>
- Date: 5 Nov 92 07:40:02 GMT
- Lines: 63
-
- *** RECREATIONAL PROGRAMMING DEPARTMENT ***
-
- All you old-timers: remember Cliff Stern? He was very active in the
- PPC heydays, especially in the field of HP-41 "m-code" programming.
-
- Well, he has an HP 48 now, but no computer, hence no access to the net
- or to System RPL or ML. But he gets a kick out of optimizing User RPL
- programs, and we often swap fun challenges over the phone.
-
- You'll enjoy Cliff Stern's latest challenges. Use 100% normal User
- RPL, with no SYSEVAL's or monkey business! These are really tests of
- your knowledge of HP-documented User RPL, not of bizarre undocumented
- HP 48 anomalies. Of course, assume default mode settings, etc.
-
- ----
-
- (1a) Write a program that takes as input a real number on level 1, and
- then drops it if it's a zero, or leaves it alone if it's not zero.
-
- (1b) Using IF-THEN-END, do the same program in 20 bytes (including the
- << >> program delimiters; use the BYTES command to check).
-
- (1c) Now do it in 15 bytes. (Hint: don't use IF-THEN-END).
-
- ----
-
- (2a) Write a program that takes as input a list of two or more reals
- on level 1, and replaces it with the sum of its elements.
-
- (2b) Now do the same program in 25 bytes (including << >> as always).
-
- (2c) If we can assume that all the elements are positive, do the same
- program in 17.5 bytes.
-
- ----
-
- (3a) Assume that there is at least one object on the stack. Write a
- program that clears the stack of everything *except* for the
- object in level 1, which is left alone. (Can be thought of as 1
- KEEP). Remember: no SYSEVALs or library function calls!
-
- (3b) Now do it in 17.5 bytes.
-
- ----
-
- (4) Place WHILE UNTIL END on level 1, just like that (without any <<
- >> program or { } list delimiters around it). Remember: no
- SYSEVALs or library function calls!
-
- ----
-
- (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.
-
- ----
-
- Problems 1 through 4 are non-obvious but are not difficult.
- Problem 5 is more difficult but very possible. My first attempt
- yielded a 115.5-byte solution; I'm sure there's a shorter way.
-
- Have fun! -Joe Horn-
-