March 10th, 2011 at 4:30:54 PM
                    permalink
                
I would like to automatically create a table of combinatorics in Excel. For instance there are 6 ways of choosing 2 things out of 4. 
The table is simple enough to construct by hand:
combin(4,2)=6
														
														
I see some third party add ins to Excel that do this. Any suggestions? Has anyone tried this kind of software before?
The table is simple enough to construct by hand:
combin(4,2)=6
| 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 
| 2 | 1 | 0 | 0 | 1 | 1 | 0 | 
| 3 | 0 | 1 | 0 | 1 | 0 | 1 | 
| 4 | 0 | 0 | 1 | 0 | 1 | 1 | 
I see some third party add ins to Excel that do this. Any suggestions? Has anyone tried this kind of software before?
                    March 10th, 2011 at 4:56:04 PM
                    permalink
                
You're just counting in binary (look vertically).  Use Dec2Bin(x) and then break it out into individual bits.
Edit: to be more specific, count from 0 to 2^N-1, separate the N bits into columns, and then count how many of them are 1. Filter by count = M, and that's your table of C(N,M).
Edit: to be more specific, count from 0 to 2^N-1, separate the N bits into columns, and then count how many of them are 1. Filter by count = M, and that's your table of C(N,M).
"In my own case, when it seemed to me after a long illness that death was close at hand, I found no little solace in playing constantly at dice." 
 -- Girolamo Cardano, 1563
 
                    March 10th, 2011 at 9:13:42 PM
                    permalink
                
It seems logical, but it is a little computationally intensive.
Combin(25,8)=1,081,575 . The filtering means you have to generate a lot of useless numbers. It might work however, but not in a spreadsheet.
Combin(25,8)=1,081,575 . The filtering means you have to generate a lot of useless numbers. It might work however, but not in a spreadsheet.
                    March 11th, 2011 at 7:30:25 AM
                    permalink
                
Try this:
http://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation
The very last method on that page should be doable in a spreadsheet (or in a VBA macro), and it won't produce any unused data.
http://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation
The very last method on that page should be doable in a spreadsheet (or in a VBA macro), and it won't produce any unused data.
"In my own case, when it seemed to me after a long illness that death was close at hand, I found no little solace in playing constantly at dice." 
 -- Girolamo Cardano, 1563
 

 
                         
                                                             
                                                             
  
  
  
 