home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / hp48 / 6932 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  1.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!newsserver.jvnc.net!netnews.upenn.edu!pobox.upenn.edu!mengwong
  2. From: mengwong@pobox.upenn.edu (Meng Weng Wong)
  3. Newsgroups: comp.sys.hp48
  4. Subject: Power Set program in User RPL
  5. Message-ID: <104480@netnews.upenn.edu>
  6. Date: 12 Jan 93 14:18:15 GMT
  7. Sender: news@netnews.upenn.edu
  8. Organization: University of Pennsylvania
  9. Lines: 32
  10. Nntp-Posting-Host: pobox.upenn.edu
  11.  
  12.  
  13. Problem: write the shortest program to generate a power set, given a set.
  14.  
  15. Definition: A power set is the set of all possible combinations of the
  16.     input set.
  17.  
  18. Example: { 1 2 3 } POWER will result in
  19.     { { }
  20.       { 1 }
  21.       { 2 }
  22.       { 3 }
  23.       { 1 2 }
  24.       { 1 3 }
  25.       { 2 3 }
  26.       { 1 2 3 }
  27.     }
  28.  
  29.     Since in set theory, an element is unique, I don't wnat to see
  30.     anything like { 2 2 } popping up.  The null element must appear.
  31.  
  32. Note:    Order doesn't matter.  { 3 2 1 } is just as good as { 1 2 3 }.
  33.  
  34. Extra Credit: Write the program recursively.
  35.  
  36. Please email me your solutions, and I will post the best few.
  37.  
  38.  
  39. -- 
  40. Cyberpunk: "These are all hot young verbal pilots who think nothing of
  41.     taking forty-thousand tons of screaming heavy metal prose and throwing
  42.     it straight at the ground in a forced power dive shedding sparks and
  43.     literary chaos only to pull up at the last possible instant shy of
  44.