C
Carnosaur
Hi all,
I am trying to write a program that will enumerate all possible
combinations of assigning 1 to 4 colors to 4 objects. For example,
there is one way to assign a single color to four objects, which might
be enumerated as:
1111
where each digit indicates an object and values indicate color.
Similarly there is one way to assign four colors to four objects:
1234
Similarly, here are the ways to assign two colors to four objects:
1112
1122
1222
1212
For my purposes, the specific colors are interchangeable (in other
words, 1112 is the same as 2221). All that matters is identifying and
enumerating patterns of shared or unique colors.
I would be extremely grateful to anyone that would help me with the
algorithm or C code for this problem. Although I can enumerate all
possibilities by hand for this simple case, I need to develop code for
the general problem of assigning (and enumerating) from 1 to k colors
to k objects. Thanks for any help!
Michael
(e-mail address removed)
I am trying to write a program that will enumerate all possible
combinations of assigning 1 to 4 colors to 4 objects. For example,
there is one way to assign a single color to four objects, which might
be enumerated as:
1111
where each digit indicates an object and values indicate color.
Similarly there is one way to assign four colors to four objects:
1234
Similarly, here are the ways to assign two colors to four objects:
1112
1122
1222
1212
For my purposes, the specific colors are interchangeable (in other
words, 1112 is the same as 2221). All that matters is identifying and
enumerating patterns of shared or unique colors.
I would be extremely grateful to anyone that would help me with the
algorithm or C code for this problem. Although I can enumerate all
possibilities by hand for this simple case, I need to develop code for
the general problem of assigning (and enumerating) from 1 to k colors
to k objects. Thanks for any help!
Michael
(e-mail address removed)