# Board index » delphi » How to get all the datas

## How to get all the datas

2003-07-09 05:18:02 PM
delphi122
Hi,
Sorry, I have another question!
I have a MIS AP.
The AP let user keyin 8 - 42 numbers,
then the AP has to response all kinds of 6 numbers from the 8 - 42
numbers.
For example:
If the user keyin (1, 2, 3, 4, 5, 6, 7)
Then AP respond - 7 kinds
(1, 2, 3, 4, 5, 6)
(1, 2, 3, 4, 5, 7)
(1, 2, 3, 4, 6, 7)
(1, 2, 3, 5, 6, 7)
(1, 2, 4, 5, 6, 7)
(1, 3, 4, 5, 6, 7)
(2, 3, 4, 5, 6, 7)
and then,
If the user keyin (1, 2, 3, 4, 5, 6, 7, 8)
Then AP responds - 28 kinds
.....
.....
.....
.....
.....
So, My question is : How to get all the datas?
Thanks!
bill

## Re:How to get all the datas

bill <XXXX@XXXXX.COM>writes
##### Quote
Hi,
Sorry, I have another question!

I have a MIS AP.
The AP let user keyin 8 - 42 numbers,
then the AP has to response all kinds of 6 numbers
from the 8 - 42 numbers.
[SNIP]
This isn't an SQL server question, it is a math question. In the future the
best place for such a question would most likely by b.p.d.students or
b.p.d.language.objectpascal.
Back to the question - this is the classic "x pick n" combinations problem.
Here is a great starting point:
mathforum.org/dr.math/faq/faq.comb.perm.html
As far as writing an algorithm, here are the basics (unfortunately I don't
have a Delphi example handy):
1) Create an array of the choices
2) Calculate the maximum number of combinations (see link above)
3) Loop through a number 0-max and use the bits in the number to represent
which elements from the array have been chosen. It works kind of like an
odometer. If you have 8 choices, the number cycles from 00000000, 00000001,
00000010...11111111.
4) Discard any that don't have the same number of one-bits as you need (6 in