Professional Documents
Culture Documents
Password
Log in
Help
Register
Remember Me?
Forum
Forum
Subscribed Threads
Advanced Search
Quick Links
Question Forums
Excel Questions
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you
can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit
from the selection below.
Become a Registered Member (free) to remove the ad that appears in the top post.
Results 1 to 10 of 18
Page 1 of 2 1 2
Last
New Member
Join Date:
Posts:
Dec 2009
9
Display
#1
andrew_sampson
Thread Tools
Share
Reply With Quote
#2
pgc01
MrExcel MVP
Join Date:
Posts:
Apr 2006
14,255
Hi Andrew
Welcome to the board
You want to calculate the Power Set of a Set.
You can try this code:
Code:
Oto Epii
pin xlct
'PCOt20
G c 07
'Cluae aPwrSt
aclts
oe e
'Sti A,dw.Rsl i C,dw adacos Ce
e n 1 on eut n 1 on n crs. l
asCZ
r :.
SbPwre(
u oeSt)
DmvlmnsA Vrat veutA Vrat
i Eeet s ain, rsl s ain
Dmlo A Ln,iA Ln
i Rw s og
s og
vlmns=ApiainTasoeRne"1,Rne"
Eeet
plcto.rnps(ag(A" ag(A
1)EdxDw))
".n(lon)
Clms":".la
oun(CZ)Cer
lo =1
Rw
Fri=1T Uon(Eeet)
o
o Budvlmns
RDmveut1T i
ei rsl( o )
Cl CmiainN(Eeet,i veut lo,1
al obntosPvlmns , rsl, Rw
,1
)
Nx i
et
EdSb
n u
SbCmiainN(Eeet A Vrat pA Ln,v
u obntosPvlmns s ain,
s og r
eutA Vrat lo A Ln,ilmn A Itgr i
sl s ain, Rw s og Eeet s nee,
IdxA Itgr
ne s nee)
DmiA Ln
i
s og
Fri=ilmn T Uon(Eeet)
o
Eeet o Budvlmns
veutine)=vlmnsi
rsl(Idx
Eeet()
I ine =pTe
f Idx
hn
lo =lo +1
Rw
Rw
Rne""&lo)Rsz( p =veut
ag(C
Rw.eie, )
rsl
Es
le
Cl obntosPvlmns , rsl, R
Test:, i + 1 a l C m i a i n N ( E e e t , p v e u t l o
w
,ine +1
Idx
)
EdI
n f
N xa, b,
e
- Write t i c, d in A1:A4
EPowerSet
d u
- run n S b
b
c
10
11
12
13
14
15
16
17
[Book1]Sheet1
Kind regards
PGC
To understand recursion, you must understand recursion.
Reply With Quote
#3
andrew_sampson
New Member
Join Date:
Posts:
Dec 2009
9
Share
Reply With Quote
#4
mountainclimber11
Board Regular
Join Date:
Posts:
Dec 2009
60
Share
Reply With Quote
#5
pgc01
MrExcel MVP
Join Date:
Posts:
Apr 2006
14,255
Hello,
I'm looking for the same thing except for permutations...ie order
does matter so for 3 #'s or letters I will get 3^1 + 3^2 + 3^3
answers, or 39. But just like his original question, I don't know
how many I'll have to start with.
Hi mountainclimber11
a
b
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[Book2]Sheet6
Share
Kind regards
PGC
To understand recursion, you must understand recursion.
Reply With Quote
#6
mountainclimber11
Board Regular
Join Date:
Posts:
Dec 2009
60
Sbcmoe)
u obz(
Dmz y)A Srn,uA Itgr vA Itgr
i , ( s tig
s nee,
s nee
DmaA Itgr bA Ln,cA Itgr dA Itg
i
s nee,
s og
s nee,
s nee
r
Dmw) g c,i j k
i (, , t , , k
z=Ary"" "" ""
ra(a, b, c)
u=Uon()+1
Budz
v=u
RDmy1T u^v 1T v,w1T u^v 1T v
ei ( o
,
o ) ( o
,
o )
Fra=1T v
o
o
Frb=1T u^vSe u^a
o
o
tp
Frc=bT b+u^( -1 -1
o
o
a
)
Frd=1T u
o
o
yc+u^( -1 *( -1,v-a+1
(
a
)
d
)
)=zd-1
(
)
Nx d c b a
et , , ,
n=u^v m=v
:
Wt CetOjc(SrpigDcinr"
ih raebet"citn.itoay)
Fri=1T n
o
o
Frj=1T m
o
o
.tmyi j)=.tmyi j)+1
Ie((, )
Ie((, )
Nx j
et
k =.es
k
ky
Fra=1T .on
o
o Cut
wi a =k( -1
(, )
ka
)
Nx a
et
.eoel
rmval
Nx i
et
Fri=1T n
o
o
g=Epy
mt
Frj=1T m g=g&Cr3)&wi j:Nx j
o
o :
h(0
(, ) et
I Nt.xssg Te
f o eit() hn
.d g Epy
Ad , mt
c =c +1
t
t
Frj=1T m wc,j =wi j:Nx j
o
o : (t )
(, ) et
From this n I
Ethread:
d f
Nx i
et
http://www.mrexcel.com/forum/showthr...44#post2164844
EdWt
n ih
Rne"1)Rsz(t m =w
ag(A".eiec, )
Thanks! S
Ed
n
Share
Reply With Quote
#7
crakonit
New Member
Join Date:
Posts:
Jan 2011
7
Hi All,
This method "PowerSet" to work the combinations out is certainly
really impressive!
Is it possible to get the PowerSet Code adjusted so it also
considers its own velements?.
I mean, when running the code based on 'A' and 'B' and 'C'
It will return:
A
B
C
AB
AC
BC
ABC
I need it to return:
A
B
C
AA
AB
A
B
B
C
A
A
A
A
A
A
B
B
B
C
C
B
C
C
AA
AB
AC
BB
BC
CC
BB
BC
CC
CC
Share
Reply With Quote
#8
pgc01
MrExcel MVP
Join Date:
Posts:
Apr 2006
14,255
SbPwreRp(
u oeStet)
DmvlmnsA Vrat veutA Vrat
i Eeet s ain, rsl s ain
Dmlo A Ln,iA Ln
i Rw s og
s og
vlmns=ApiainTasoeRne"1,Rne"
Eeet
plcto.rnps(ag(A" ag(A
1)EdxDw))
".n(lon)
Clms":".la
oun(CZ)Cer
lo =1
Rw
Fri=1T Uon(Eeet)
o
o Budvlmns
RDmveut1T i
ei rsl( o )
Cl CmiainN(Eeet,i veut lo,1
al obntosPvlmns , rsl, Rw
,1
)
Nx i
et
EdSb
n u
SbCmiainN(Eeet A Vrat pA Ln,v
u obntosPvlmns s ain,
s og r
eutA Vrat lo A Ln,ilmn A Ln,in
sl s ain, Rw s og Eeet s og Id
e A Ln)
x s og
DmiA Ln
i
s og
Fri=ilmn T Uon(Eeet)
o
Eeet o Budvlmns
veutine)=vlmnsi
rsl(Idx
Eeet()
I ine =pTe
f Idx
hn
lo =lo +1
Rw
Rw
Rne""&lo)Rsz( p =veut
ag(C
Rw.eie, )
rsl
Es
le
Cl CmiainN(Eeet,p veut lo
al obntosPvlmns , rsl, R
w i ine +1
, , Idx
)
EdI
n f
Nx i
et
EdSb
n u
b
c
10
11
12
13
14
15
16
17
18
19
20
21
[Book1]Sheet2
Share
Kind regards
PGC
#9
crakonit
New Member
Join Date:
Posts:
Jan 2011
7
Thanks.
This is exactly what I was after!
Thank you ever so much for doing this =)
Share
Reply With Quote
#10
crakonit
New Member
Join Date:
Posts:
Jan 2011
7
Hi Again...
What would be the formula to work out the results of CombRept
based on given no of elements?
Say I have 2 elements, I need to know (before I run CombRept):
how many rows of data will contain 1 element (=2),
how many rows of data will contain 2 elements (=3).
Say I have 4 elements, I need to know (before I run CombRept):
how many rows of data will contain 1 elements(=4),
how many rows of data will contain 2 elements(=10)
how many rows of data will contain 3 elements (=20)
how many rows of data will contain 4 elements (=35)
The build-in COMBIN does really tell the that.
Thanks!
Share
Reply With Quote
Page 1 of 2 1 2
Last
Twitter
Linked In
Google
Reddit
StumbleUpon
Posting Permissions
BB code is On
Smilies are On
[IMG] code is On
[VIDEO] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Rules
Excel 2007
-- vB4 Default Style
Excel Formula
Excel Help
VBA
Contact Us Ask Mr. Excel - Tips and Solutions for Excel Privacy Statement Terms of
Service Top
All times are GMT -4. The time now is 05:37 PM.
Powered by vBulletin Version 4.2.0
Copyright 2014 vBulletin Solutions, Inc. All rights reserved.
All contents Copyright 1998-2014 by MrExcel Consulting.