Thread: RE: [Dev-C++] Code for all combinations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Rodolfo D. <rod...@la...> - 2003-07-23 04:31:18
|
Hi,=20
just curiosity, is that a school assignment? An idea would be to nest =
six for statements.
Regards
Rodolfo d'Ettorre
-----Original Message-----
From: Andr=E9 Mac=E1rio Barros [mailto:and...@su...]
Sent: Wednesday, 23 July 2003 1:54 PM
To: Dev-Cpp-Users
Subject: [Dev-C++] Code for all combinations
Dear Users,
I need to test all possibilities in a specific code.
I couldn=B4t realize how I can generate theese possibilities with two
for=B4s.
Here is the problem:
Suppose you have a vector like
int vect[6]=3D{0};
How could be a C code to have (print for example) all possible
combinations in the
six positions from the range 0 to 10?
the output is something like:
0 , 0, 0, 0, 0, 0
1 , 0, 0, 0, 0, 0
2 , 0, 0, 0, 0, 0
...
10, 0, 0, 0, 0, 0
0 , 1, 0, 0, 0, 0
0 , 2, 0, 0, 0, 0
...
0 ,10, 0, 0, 0, 0
1, 1, 0, 0, 0, 0
2, 1, 0, 0, 0, 0
...
10, 1, 0, 0, 0, 0
1 , 2, 0, 0, 0, 0
2 , 2, 0, 0, 0, 0
...
10, 2, 0, 0, 0, 0
...
...
10,10,10,10,10,10
Some repetition values are allowed, that is, if you have to
reset all values to begin the counting to another digit, etc.
Regards
Andre
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Hossein H. <ult...@em...> - 2003-07-27 10:46:28
|
Dear Andre, > How could be a C code to have (print for example) all possible > combinations in the Do you have to use poor C? or can you use C++ as well? If C++ is OK, it seems that I can give you neat solutions. It is enough to just keep in touch! Regards, --Hossein -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup CareerBuilder.com has over 400,000 jobs. Be smarter about your job search http://corp.mail.com/careers |
|
From: Rafael d. V. H. <rde...@in...> - 2003-07-23 06:11:00
|
It's like counting in base 11 (6 digits, in reverse order).
#define MAX 11L*11L*11L*11L*11L*11L // 11^6 -> 1.7e6
...
unsigned long n, m;
int i;
int vect[6]={0};
...
for(n=0; n<MAX; n++) {
m=n;
for(i=5; i>=0; i--) {
vect[i]=m%11;
m/=11;
printf("%ul, ", vect[i]);
}
printf("\n");
}
...
It's easy to "unroll" the inner loop in 6 steps and leave only one loop.
-----Mensaje original-----
De: dev...@li...
[mailto:dev...@li...]En nombre de Rodolfo
Dettorre
Enviado el: miércoles 23 de julio de 2003 6:31
Para: André Macário Barros; Dev-Cpp-Users
Asunto: RE: [Dev-C++] Code for all combinations
Hi,
just curiosity, is that a school assignment? An idea would be to nest six
for statements.
Regards
Rodolfo d'Ettorre
-----Original Message-----
From: André Macário Barros [mailto:and...@su...]
Sent: Wednesday, 23 July 2003 1:54 PM
To: Dev-Cpp-Users
Subject: [Dev-C++] Code for all combinations
Dear Users,
I need to test all possibilities in a specific code.
I couldn´t realize how I can generate theese possibilities with two
for´s.
Here is the problem:
Suppose you have a vector like
int vect[6]={0};
How could be a C code to have (print for example) all possible
combinations in the
six positions from the range 0 to 10?
the output is something like:
0 , 0, 0, 0, 0, 0
1 , 0, 0, 0, 0, 0
2 , 0, 0, 0, 0, 0
...
10, 0, 0, 0, 0, 0
0 , 1, 0, 0, 0, 0
0 , 2, 0, 0, 0, 0
...
0 ,10, 0, 0, 0, 0
1, 1, 0, 0, 0, 0
2, 1, 0, 0, 0, 0
...
10, 1, 0, 0, 0, 0
1 , 2, 0, 0, 0, 0
2 , 2, 0, 0, 0, 0
...
10, 2, 0, 0, 0, 0
...
...
10,10,10,10,10,10
Some repetition values are allowed, that is, if you have to
reset all values to begin the counting to another digit, etc.
Regards
Andre
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Per W. <pw...@ia...> - 2003-07-23 08:38:24
|
A slightly more efficient solution for the suspected school assignment:
#define BASE 11
#define MAX_DIGITS 6
int digit,vec[MAX_DIGITS];
for (;;) {
// This loop is also easy to unroll...
for (digit =3D 0; digit < MAX_DIGITS; digit++) {
if (++vec[digit] < BASE) break;
vec[digit] =3D 0;
}
if (digit >=3D MAX_DIGITS) break;
print(xx);
}
/Per W
On Wed, 23 Jul 2003, Rafael del Valle Huerta wrote:
> It's like counting in base 11 (6 digits, in reverse order).
>
> #define MAX 11L*11L*11L*11L*11L*11L // 11^6 -> 1.7e6
> ...
> unsigned long n, m;
> int i;
> int vect[6]=3D{0};
> ...
> for(n=3D0; n<MAX; n++) {
> m=3Dn;
> for(i=3D5; i>=3D0; i--) {
> vect[i]=3Dm%11;
> m/=3D11;
> printf("%ul, ", vect[i]);
> }
> printf("\n");
> }
> ...
>
> It's easy to "unroll" the inner loop in 6 steps and leave only one loop.
>
>
>
> -----Mensaje original-----
> De: dev...@li...
> [mailto:dev...@li...]En nombre de Rodolfo
> Dettorre
> Enviado el: mi=E9rcoles 23 de julio de 2003 6:31
> Para: Andr=E9 Mac=E1rio Barros; Dev-Cpp-Users
> Asunto: RE: [Dev-C++] Code for all combinations
>
>
> Hi,
>
> just curiosity, is that a school assignment? An idea would be to nest si=
x
> for statements.
>
> Regards
>
> Rodolfo d'Ettorre
>
> -----Original Message-----
> From: Andr=E9 Mac=E1rio Barros [mailto:and...@su...]
> Sent: Wednesday, 23 July 2003 1:54 PM
> To: Dev-Cpp-Users
> Subject: [Dev-C++] Code for all combinations
>
>
> Dear Users,
>
> I need to test all possibilities in a specific code.
> I couldn=B4t realize how I can generate theese possibilities with two
> for=B4s.
> Here is the problem:
>
> Suppose you have a vector like
> int vect[6]=3D{0};
>
> How could be a C code to have (print for example) all possible
> combinations in the
> six positions from the range 0 to 10?
> the output is something like:
> 0 , 0, 0, 0, 0, 0
> 1 , 0, 0, 0, 0, 0
> 2 , 0, 0, 0, 0, 0
> ...
> 10, 0, 0, 0, 0, 0
> 0 , 1, 0, 0, 0, 0
> 0 , 2, 0, 0, 0, 0
> ...
> 0 ,10, 0, 0, 0, 0
> 1, 1, 0, 0, 0, 0
> 2, 1, 0, 0, 0, 0
> ...
> 10, 1, 0, 0, 0, 0
> 1 , 2, 0, 0, 0, 0
> 2 , 2, 0, 0, 0, 0
> ...
> 10, 2, 0, 0, 0, 0
> ...
> ...
> 10,10,10,10,10,10
>
> Some repetition values are allowed, that is, if you have to
> reset all values to begin the counting to another digit, etc.
>
> Regards
> Andre
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: <and...@su...> - 2003-07-23 11:11:31
|
Yes! It is.
I am working with genetic algorithms (programming thechnique
that mimics the biological behavior to solve the problems.
A "Darwinian" way to do that. A random set "population" of
candidates of solution begins with mutations, reproductions,
cross-overs, etc, to find the best family of solutions and
its best representant. It´s a sthocastic/heuristic way to
solve NP-hard problems) and I am interested to compare
a simple combinatorial analysis with the GA method. The simple
combinatorial analysis program will test all the
10*10*10*10*10*10=10^6 possible results. With the results
I will make some graphical comparisons.
Fishing this phase, I will need to develop some advanced
"cross-over" techniques.
Finishing this other phase, I will need to apply theese
results in a FPGA digital filter of specificy frequencies.
Thank you
Andre
-----Mensagem original-----
De: Rodolfo Dettorre [mailto:rod...@la...]
Enviada em: quarta-feira, 23 de julho de 2003 01:31
Para: André Macário Barros; Dev-Cpp-Users
Assunto: RE: [Dev-C++] Code for all combinations
Hi,
just curiosity, is that a school assignment? An idea would be to nest six
for statements.
Regards
Rodolfo d'Ettorre
-----Original Message-----
From: André Macário Barros [mailto:and...@su...]
Sent: Wednesday, 23 July 2003 1:54 PM
To: Dev-Cpp-Users
Subject: [Dev-C++] Code for all combinations
Dear Users,
I need to test all possibilities in a specific code.
I couldn´t realize how I can generate theese possibilities with two
for´s.
Here is the problem:
Suppose you have a vector like
int vect[6]={0};
How could be a C code to have (print for example) all possible
combinations in the
six positions from the range 0 to 10?
the output is something like:
0 , 0, 0, 0, 0, 0
1 , 0, 0, 0, 0, 0
2 , 0, 0, 0, 0, 0
...
10, 0, 0, 0, 0, 0
0 , 1, 0, 0, 0, 0
0 , 2, 0, 0, 0, 0
...
0 ,10, 0, 0, 0, 0
1, 1, 0, 0, 0, 0
2, 1, 0, 0, 0, 0
...
10, 1, 0, 0, 0, 0
1 , 2, 0, 0, 0, 0
2 , 2, 0, 0, 0, 0
...
10, 2, 0, 0, 0, 0
...
...
10,10,10,10,10,10
Some repetition values are allowed, that is, if you have to
reset all values to begin the counting to another digit, etc.
Regards
Andre
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: <and...@su...> - 2003-07-27 18:10:21
|
Thank you, Mr. Hossein, But the codes must be written in C, to be portable for FPGA/VHDL. Andre === >Message: 4 >From: "Hossein Haeri" <ult...@em...> >To: dev...@li... >Date: Sun, 27 Jul 2003 05:43:22 -0500 >Subject: Re: [Dev-C++] Code for all combinations > >Dear Andre, > >> How could be a C code to have (print for example) all possible >> combinations in the > >Do you have to use poor C? or can you use C++ as well? If C++ is OK, >it seems that I can give you neat solutions. It is enough to just keep >in touch! > >Regards, >--Hossein >-- |