I am searching an algorithm for testing all possibilities in an 2D-array

Quote:

> I have an 2D-array and have to set a fixed number of "flags" in all

> possible variations on it.... So it is a "binary" problem that should

> simulate all possible situation for X bits on it...

> But the more I think about it the more I get confused....

> Does anybody have something like that, or an idea to help me??

Dimensions are a figment of your imagination. Have a look at this:

#define R 42 /* the number of rows */

#define C 13 /* the number of columns */

#define N (R*C) /* the population */

#define K ... /* the sample<= N */

tydedef unsigned char flag_t;

typedef union {

flag_t your_problem[R][C];

flag_t simple_stuff[N];

} data_t;

data_t my_data;

Now, rip some C(n, k) implementing algorithm from the net and

pass it my_data.simple_stuff to chew on. After that, have a look

at my_data.your_problem.

kind regards,

ps. comp.programming would've been a more appropriate group for this

type of questions ...