home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!newsserver.jvnc.net!netnews.upenn.edu!pobox.upenn.edu!mengwong
- From: mengwong@pobox.upenn.edu (Meng Weng Wong)
- Newsgroups: comp.sys.hp48
- Subject: Power Set program in User RPL
- Message-ID: <104480@netnews.upenn.edu>
- Date: 12 Jan 93 14:18:15 GMT
- Sender: news@netnews.upenn.edu
- Organization: University of Pennsylvania
- Lines: 32
- Nntp-Posting-Host: pobox.upenn.edu
-
-
- Problem: write the shortest program to generate a power set, given a set.
-
- Definition: A power set is the set of all possible combinations of the
- input set.
-
- Example: { 1 2 3 } POWER will result in
- { { }
- { 1 }
- { 2 }
- { 3 }
- { 1 2 }
- { 1 3 }
- { 2 3 }
- { 1 2 3 }
- }
-
- Since in set theory, an element is unique, I don't wnat to see
- anything like { 2 2 } popping up. The null element must appear.
-
- Note: Order doesn't matter. { 3 2 1 } is just as good as { 1 2 3 }.
-
- Extra Credit: Write the program recursively.
-
- Please email me your solutions, and I will post the best few.
-
-
- --
- Cyberpunk: "These are all hot young verbal pilots who think nothing of
- taking forty-thousand tons of screaming heavy metal prose and throwing
- it straight at the ground in a forced power dive shedding sparks and
- literary chaos only to pull up at the last possible instant shy of
-