Re: Combination of binary variables
- From: "Jim Langston" <tazmaster@xxxxxxxxxxxxxx>
- Date: Thu, 29 Mar 2007 19:37:40 -0700
"Nightfall" <chesbobba@xxxxxxxxx> wrote in message
news:1175203021.816435.48620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dear friends,
this is my problem: let's take an array of n binary variables. I need
an algorithm to write every possible combination of those variables.
If, say, n = 3, the algorithm should output:
000
001
010
100
011
110
101
111
I have to implement this algorithm in Mosel language (the language
used in Xpress-Optimizer), but this does't matter: can you help me
with just some "pseudo-code", please?
Why not just count up to 111 and display the binary value? I.E.
int Bits = 3;
for ( int i = 0; i < pow( 2, 3 ); ++i )
// output i as binary
Outputing a decimal value in some base is not difficult.
.
- References:
- Combination of binary variables
- From: Nightfall
- Combination of binary variables
- Prev by Date: Re: Combination of binary variables
- Next by Date: Re: bison and valgrind
- Previous by thread: Re: Combination of binary variables
- Next by thread: Re: Combination of binary variables
- Index(es):
Relevant Pages
|