468,512 Members | 1,375 Online

# possible combination of numbers

hi,
I'll explain fastly the program that i'm doing..
the computer asks me to enter the cardinal of a set X ( called "dimX"
type integer)where X is a table of one dimension
and then to fill it with numbers X[i];
then the computer asks me how many subsets i have (nb_subset type
(integer))
then,i have to enter for every sebset the card, and then to fill it,
we'll have a two tables , one called cardY which contains nb_subset
elements,and every element is the cardinal of every Yi
example:
X={0, 1, 2, 3, 4, 5,6, 7,8, 9, 10} dimX= 11

Y1={5, 8, 9, 7} cardY=4
Y2={2, 0, 7, 6, 4, 10} cardY=6
Y3={8, 10, 6, 4, 3, 1} cardY=6
Y4={9, 7, 5, 3, 1, 10, 7} ...
Y5={3, 8, 1, 9, 6} ...
Y6={1, 2, 3} ...
Y7={4, 9, 6, 3, 0} card=4

and then a table of two dimensions, called TY(corresponding to Table Y)
which contains all the values of Yi
5 8 9 7 * * *
2 0 7 6 4 10 *
8 10 6 4 3 1 *
9 7 5 3 1 10 7
3 8 1 9 6 * *
1 2 3 * * * *
4 9 6 3 0 * *

(sure i'll lose memory, but its okay) i know that using chained lists
is best , but its okay

now the problem is to find all the combination possible of Yi which is
equal to X
example :

X= {1, 2, 3, 4, 5}
Y1= {2, 4, 5}; Y2= {1, 2, 4} ; Y3= {2, 3, 5} ; Y4= {3, 5} ; Y5= {1, 3,
4}
S= {1, 3, 5} S is a solution, N.B. where 1,3,and 5 are not elements,
but they are the indicies of Y
in this case Y1, Y3 and Y5

this was the subject of my mini project,
now ,my algorithm is to make a table containing all the possible
combinations of the indicies,example :
if the nb_subsets is 3
1
2
3
1,2
1,3
2,3
1,2,3
and then,i bring the Y1 and compare it to X, if the same, i return S=
{1}
if not , i try Y2,
then Y3
then Y1 and Y2 , if Y1 U Y2 = X , then the solution S={1,2}
and i continue

my question that i'd like to have your help in is :
HOW TO MAKE A TABLE OF THREE DIMENSIONS CONTAINING ALL THE POSSIBLE
INDICIIES, like the example above.
i don't know if it is possible,but it is something that i need
urgently,cause i have to give back my work on monday(in less than 2
days)
thanks a lot for your help..
sincerely

Sep 2 '06 #1
1 6596 AAA wrote:
hi,
I'll explain fastly the program that i'm doing..
the computer asks me to enter the cardinal of a set X ( called "dimX"
type integer)where X is a table of one dimension
and then to fill it with numbers X[i];
Since X is a **set** does this mean that the numbers
you have to enter are distinct ?
then the computer asks me how many subsets i have (nb_subset type
(integer))
then,i have to enter for every sebset the card, and then to fill it,
If you know the subset then it automatically determines
its cardinal and its elements. So I don't see why you have
to enter the card and fill it.
we'll have a two tables , one called cardY which contains nb_subset
elements,and every element is the cardinal of every Yi
example:
X={0, 1, 2, 3, 4, 5,6, 7,8, 9, 10} dimX= 11

Y1={5, 8, 9, 7} cardY=4
Y2={2, 0, 7, 6, 4, 10} cardY=6
Y3={8, 10, 6, 4, 3, 1} cardY=6
Y4={9, 7, 5, 3, 1, 10, 7} ...
Y5={3, 8, 1, 9, 6} ...
Y6={1, 2, 3} ...
Y7={4, 9, 6, 3, 0} card=4

and then a table of two dimensions, called TY(corresponding to Table Y)
which contains all the values of Yi
5 8 9 7 * * *
2 0 7 6 4 10 *
8 10 6 4 3 1 *
9 7 5 3 1 10 7
3 8 1 9 6 * *
1 2 3 * * * *
4 9 6 3 0 * *

(sure i'll lose memory, but its okay) i know that using chained lists
is best , but its okay

now the problem is to find all the combination possible of Yi which is
equal to X
example :

X= {1, 2, 3, 4, 5}
Y1= {2, 4, 5}; Y2= {1, 2, 4} ; Y3= {2, 3, 5} ; Y4= {3, 5} ; Y5= {1, 3,
4}
S= {1, 3, 5} S is a solution, N.B. where 1,3,and 5 are not elements,
but they are the indicies of Y
in this case Y1, Y3 and Y5

this was the subject of my mini project,
now ,my algorithm is to make a table containing all the possible
combinations of the indicies,example :
if the nb_subsets is 3
1
2
3
1,2
1,3
2,3
1,2,3
and then,i bring the Y1 and compare it to X, if the same, i return S=
{1}
if not , i try Y2,
then Y3
then Y1 and Y2 , if Y1 U Y2 = X , then the solution S={1,2}
and i continue

my question that i'd like to have your help in is :
HOW TO MAKE A TABLE OF THREE DIMENSIONS CONTAINING ALL THE POSSIBLE
INDICIIES, like the example above.
i don't know if it is possible,but it is something that i need
urgently,cause i have to give back my work on monday(in less than 2
days)
I'm sure it is possible if you manage to actually explain
what you need to do. So far I ain't got a clue. To be
perfectly honest with you it doesn't look like you can
manage for Monday but we'll see.

Sep 2 '06 #2

### This discussion thread is closed

Replies have been disabled for this discussion.

### Similar topics

 6 posts views Thread by Chris Lasher | last post: by 36 posts views Thread by rbt | last post: by 9 posts views Thread by tony collier | last post: by 6 posts views Thread by aka_eu | last post: by 4 posts views Thread by kivan.maharaj | last post: by 8 posts views Thread by Mir Nazim | last post: by 9 posts views Thread by Andy | last post: by 4 posts views Thread by RSH | last post: by 7 posts views Thread by Mysterydave | last post: by reply views Thread by ravipankaj | last post: by reply views Thread by slotstar | last post: by 7 posts views Thread by isladogs | last post: by reply views Thread by captainhaddock | last post: by reply views Thread by sakshijain10388 | last post: by 1 post views Thread by fmendoza | last post: by 3 posts views Thread by Davism4 | last post: by reply views Thread by jimatqsi | last post: by reply views Thread by ajay sahare | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.