Article View: comp.lang.pascal.ansi-iso
Article #5Re: all possible combinations
From: Wolf Behrenhoff
Date: Mon, 06 Mar 2000 00:00
Date: Mon, 06 Mar 2000 00:00
47 lines
1893 bytes
1893 bytes
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
number of combinations
= number of combinations 1 of 3
+ number of combinations 2 of 3
+ number of combinations 3 of 3
3 3 3
= ( ) + ( ) + ( )
1 2 3
= 3+3+1
= 7
a
with ( ) = a! / (b! (b-a)!)
b
I think you missed the combination 0 of 3 in your list. Unless this
was 3
intended, you have to add ( ) = 1. Then the result would be 8.
0
n
---
\ n
generalized: num of c = > ( ) for a set with n elements.
/ k
---
k=0
Translating this into Pascal is up to you.
Wolf
Technical Details
Message-ID:
<38C3CD72.F6206FC2@gmx.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<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: 10c950,77a4248f898f7bd2 X-Google-Attributes: gid10c950,public X-Google-Thread: 10261c,77a4248f898f7bd2 X-Google-Attributes: gid10261c,public X-Google-Thread: 108ebd,77a4248f898f7bd2 X-Google-Attributes: gid108ebd,public From: Wolf Behrenhoff <wolf.behrenhoff@gmx.net> Subject: Re: all possible combinations Date: 2000/03/06 Message-ID: <38C3CD72.F6206FC2@gmx.net> X-Deja-AN: 593841083 Content-Transfer-Encoding: 7bit References: <89v8r3$vag$1@nnrp1.deja.com> X-Accept-Language: de-DE,de,en Content-Type: text/plain; charset=us-ascii X-Trace: fu-berlin.de 952356336 3211143 149.225.70.4 (16 [17670]) Organization: me@home Mime-Version: 1.0 Newsgroups: comp.lang.pascal.ansi-iso,comp.lang.pascal.misc,borland.public.turbopascal,comp.lang.pascal.borland