Hi
I am stumped on a complex combination problem. I need to create all possible
combinations to fill grids 7 columns wide with set parameter restrictions.
Parameters are: 1) the number of columns the grid will take 2) the number of
times 'x' is to appear in the columns, going downwards 3) the maximum number
of spaces before an 'x' 4) the minimum number of 'x' in a row 5) the maximum
number of x in a row.
For example BuildGrids(3,1,6,2,3) might produce
000000x - this row has six spaces
x00xxx0 - this row has three x
0xx0000 - this row has two xs
Each column contains one and only one 'x' the maximum number of spaces is 6,
the minimum number of times 'x' appears together is 2.
This should keep producing different combinations that fit the rules until
all possible combinations are exhausted.
In the variations produced, we don't need to achieve either the maximum or
minimum number of x in a row. It just need to fall within the parameters.
BuildGrid(4,2,4,1,6) might produce
00xx00x
xx00xxx
xxx0xx0
000x000
The combination of rows two and three produce six x in a row.

Signature
Stevie
"Build a man a fire and he will be warm for one night. Set a man on fire,
and he will be warm for the rest of his life." ~ Sun-Tzu on Fire
Tyro - 03 Feb 2008 06:23 GMT
Would the formula 2^7 help you? 2^7 = 128 combinations
As in: 000000x, 00000x0, 00000xx, 0000x00, 0000x0x, 0000xx0, 0000xxx,
000x000 etc? This is binary arithmetic.
Tyro
> Hi
>
[quoted text clipped - 30 lines]
>
> The combination of rows two and three produce six x in a row.
Joosy - 03 Feb 2008 08:45 GMT
Perhaps if I was 35 years closer to learning advanced maths...
However, it is a start. If I start on something smaller (say, on a scale of
2^4), I may be able to work it out.

Signature
Stevie
"Build a man a fire and he will be warm for one night. Set a man on fire,
and he will be warm for the rest of his life."
~ Sun-Tzu on Fire
> Would the formula 2^7 help you? 2^7 = 128 combinations
> As in: 000000x, 00000x0, 00000xx, 0000x00, 0000x0x, 0000xx0, 0000xxx,
[quoted text clipped - 37 lines]
>>
>> The combination of rows two and three produce six x in a row.
Joosy - 04 Feb 2008 23:46 GMT
OK, I have stage one working now and can generate all the 0X0.... <bg>
required. The rest should just be a case of pruning out data that don't fit
the rules on the fly and add the remainder to an array before creating
combinations and pruning the combinations using the same rules.
Anyone know where to grab a ready rolled function to pull all possible
combinations and permutations of elements in as array using a parameter of
the number of elements in a group?
Example, CombArray(2) in a three element array (1,2,3) would return:
12
13
21
23
31
21

Signature
Stevie
"Build a man a fire and he will be warm for one night. Set a man on fire,
and he will be warm for the rest of his life." ~ Sun-Tzu on Fire
> Perhaps if I was 35 years closer to learning advanced maths...
>
[quoted text clipped - 42 lines]
>>>
>>> The combination of rows two and three produce six x in a row.
Herbert Seidenberg - 06 Feb 2008 16:25 GMT
This will flag rows and columns that
do not meet rules 2 to 5
http://www.freefilehosting.net/download/3bhd7
Tyro - 03 Feb 2008 06:24 GMT
Actually 128 if we include 0000000
> Hi
>
[quoted text clipped - 30 lines]
>
> The combination of rows two and three produce six x in a row.
Bob I - 06 Feb 2008 16:38 GMT
> Hi
>
[quoted text clipped - 29 lines]
>
> The combination of rows two and three produce six x in a row.
There seems to be some rules that are not true. For instance
000000x - this row has six spaces violates
minimum number of times 'x' appears together is 2
xx00xxx
xxx0xx0
The combination of rows two and three produce six x in a row. violates
Each column contains one and only one 'x'