🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.ansi-iso
Article #4

Re: all possible combinations

#4
From: Bob Schor
Date: Mon, 06 Mar 2000 00:00
43 lines
2125 bytes
Here's one way to think about it, and possibly come up with an
algorithm.  First, how many combinations are there of three things?
[You listed 7].  How about 2 things?  One thing?  Is the pattern
obvious?  Next, given N things, each "thing"  is either a member of a
particular combination or it is not, i.e. there are two possible
"states" for each of the N things.  You now only need to enumerate (i.e.
count) them.  If you can figure out the "natural" mapping between these
N things and numbers, your problem will be mostly solved.

Bob Schor
Pascal Enthusiast

Andrew wrote:

> Anyone have any pascal code for all possible combinations of a set?
>
> So if we start with '1','2','3' the possible combinations are:
>
> 1
> 2
> 3
> 1 2
> 1 3
> 2 3
> 1 2 3
>
> This seems to be a FAQ on discussion groups in general, but
> I could not find anything in Pascal.  I found some C++ code
> in another group but it looks like bad pseudocode to me -- I'm
> kindof a pascal diehard.  But I'm not a big programmer
> and this problem has my brain in knots right now.
>
> A response in any flavor of pascal would be much appreciated.
>
> TIA,
>
>   Andrew
> --
> Andrew
> noymer@my-deja.com
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Technical Details
Message-ID: <38C39F8A.60C3CCCE@pitt.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <89v8r3$vag$1@nnrp1.deja.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111659,77a4248f898f7bd2
X-Google-Attributes: gid111659,public
X-Google-Thread: 10261c,77a4248f898f7bd2
X-Google-Attributes: gid10261c,public
X-Google-Thread: 10c950,77a4248f898f7bd2
X-Google-Attributes: gid10c950,public
X-Google-Thread: 108ebd,77a4248f898f7bd2
X-Google-Attributes: gid108ebd,public
From: Bob Schor <bschor@pitt.edu>
Subject: Re: all possible combinations
Date: 2000/03/06
Message-ID: <38C39F8A.60C3CCCE@pitt.edu>
X-Deja-AN: 593792014
Content-Transfer-Encoding: 7bit
References: <89v8r3$vag$1@nnrp1.deja.com>
X-Accept-Language: en,pdf
Content-Type: text/plain; charset=us-ascii
Organization: University of Pittsburgh
Mime-Version: 1.0
Newsgroups: comp.lang.pascal.ansi-iso,comp.lang.pascal.misc,borland.public.turbopascal,comp.lang.pascal.borland