home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.msdos.programmer
- Path: sparky!uunet!caen!sdd.hp.com!apollo.hp.com!netnews
- From: holbrook@apollo.HP.COM (Alan R. Holbrook)
- Subject: 'All Possible Combinations' Algorithm
- Sender: usenet@apollo.hp.com (Usenet News)
- Message-ID: <By109I.HEt@apollo.hp.com>
- Date: Fri, 20 Nov 1992 17:51:17 GMT
- Nntp-Posting-Host: jurgen.ch.apollo.hp.com
- Organization: Hewlett-Packard Company, Chelmsford, MA
- Keywords: combinations
- Lines: 24
-
- Can someone provide me with an algorithm suitable for writing a program
- to dump all possible combinations of 'n' elements taken 'm' at a time?
- That is, given the string 'abcdefghijklmnop', I'd like to be able to produce
- all possible combinations of, say, 'abcde', then of 'abcdf', or of 'cfilnop'
- then 'aceghilmp', etc. I think you get the idea.
-
- I'm sure anyone who has taken any statistics knows the formula for doing
- this, but I never took any statistics.
-
- I know, by the way, that I'm talking ._!LOTS!_. of combinations. I don't
- really need to be able to print or file all of them, I just need to know
- how to.
-
- Oh, yeah, in case anyone is tempted to wonder, this isn't for a class or any
- other kind of assignment. Actually, I need to be able to demonstrate a point
- to my wife...
-
- Thanks,
- Alan Holbrook
- holbrook@apollo.hp.com
- No .sig, I just post on impulse.
-
-
-
-