Velocity Reviews > C++ > Permutation lists?? Really Need Help

# Permutation lists?? Really Need Help

Roger B.
Guest
Posts: n/a

 09-25-2003
Hello,

I am working on a personal interest project and have been racking my brain
on this problem for about 5 hours total now, and tracking through old
newsgroup posts but haven't figuried it out yet so heres my question.

I want to be able to make a list of all possible combinations (repitiions
are allowed) of numbers where X is a arbitrary initeger between something
like 0 and 100
and the number of x's is arbitrary as well in this example 10 x's are
present.

x,x,x,x,x,x,x,x,x,x

I want to find all possible combinations for this. In the end I would have
a list of all possible combinations of the x's in groups of ten whre each x
would be a number between 0 and 100.

Thanks for any help.

Buster Copley
Guest
Posts: n/a

 09-25-2003
Roger B. wrote:

> I am working on a personal interest project and have been racking my brain
> on this problem for about 5 hours total now [...]

I'm not sure I believe that.

> I want to be able to make a list of all possible combinations (repitiions
> are allowed) of numbers where X is a arbitrary initeger between something
> like 0 and 100
> and the number of x's is arbitrary as well in this example 10 x's are
> present.
>
> x,x,x,x,x,x,x,x,x,x
>
> I want to find all possible combinations for this. In the end I would have
> a list of all possible combinations of the x's in groups of ten whre each x
> would be a number between 0 and 100.

You do know there are 100 000 000 000 000 000 000, right? Think
of a systematic way of writing them. You might start like this:

0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,1
0,0,0,0,0,0,0,0,2
0,0,0,0,0,0,0,0,3
0,0,0,0,0,0,0,0,4

The Arabs had this all worked out many centuries ago, and
I'm pretty sure they didn't need C++ to do it.

Good luck,
Buster.

Thore B. Karlsen
Guest
Posts: n/a

 09-25-2003
On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <(E-Mail Removed)>
wrote:

>Hello,
>
> I am working on a personal interest project and have been racking my brain
>on this problem for about 5 hours total now, and tracking through old
>newsgroup posts but haven't figuried it out yet so heres my question.
>
>I want to be able to make a list of all possible combinations (repitiions
>are allowed) of numbers where X is a arbitrary initeger between something
>like 0 and 100
>and the number of x's is arbitrary as well in this example 10 x's are
>present.
>
>x,x,x,x,x,x,x,x,x,x
>
>I want to find all possible combinations for this. In the end I would have
>a list of all possible combinations of the x's in groups of ten whre each x
>would be a number between 0 and 100.

If you have a list of numbers that you would like to make permutations
of, std::next_permutation() will do the job for you. If you want to
count up every X from 0 to 100 you'll have to do that yourself, but it's
easy.

--
Be seeing you.

Roger B.
Guest
Posts: n/a

 09-25-2003
That is not it. Not all numbers from 1 to 100 could be used in a group of
10 x's. And Numbers could be repeated in the group of 10's. I need all
combinations. And there are to many to find by hand, plus to do it by hand
would end up being very confusing after a while. This is not just a count
up of loops or what else. It is a lot more complicated than that.

PS. TO BUSTER COPLEY - I don't bullsh** on my posts . It is a personal
interest project. And I have worked on it for about 5 hours. Thank You.
"Thore B. Karlsen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <(E-Mail Removed)>
> wrote:
>
> >Hello,
> >
> > I am working on a personal interest project and have been racking my

brain
> >on this problem for about 5 hours total now, and tracking through old
> >newsgroup posts but haven't figuried it out yet so heres my question.
> >
> >I want to be able to make a list of all possible combinations (repitiions
> >are allowed) of numbers where X is a arbitrary initeger between something
> >like 0 and 100
> >and the number of x's is arbitrary as well in this example 10 x's are
> >present.
> >
> >x,x,x,x,x,x,x,x,x,x
> >
> >I want to find all possible combinations for this. In the end I would

have
> >a list of all possible combinations of the x's in groups of ten whre each

x
> >would be a number between 0 and 100.

>
> If you have a list of numbers that you would like to make permutations
> of, std::next_permutation() will do the job for you. If you want to
> count up every X from 0 to 100 you'll have to do that yourself, but it's
> easy.
>
> --
> Be seeing you.

Alf P. Steinbach
Guest
Posts: n/a

 09-25-2003

On Thu, 25 Sep 2003 02:50:43 GMT, "Roger B." <(E-Mail Removed)> wrote:

>"Thore B. Karlsen" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed).. .
>> On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <(E-Mail Removed)>
>> wrote:
>>
>> >Hello,
>> >
>> > I am working on a personal interest project and have been racking my

>brain
>> >on this problem for about 5 hours total now, and tracking through old
>> >newsgroup posts but haven't figuried it out yet so heres my question.
>> >
>> >I want to be able to make a list of all possible combinations (repitiions
>> >are allowed) of numbers where X is a arbitrary initeger between something
>> >like 0 and 100
>> >and the number of x's is arbitrary as well in this example 10 x's are
>> >present.
>> >
>> >x,x,x,x,x,x,x,x,x,x
>> >
>> >I want to find all possible combinations for this. In the end I would

>have
>> >a list of all possible combinations of the x's in groups of ten whre each

>x
>> >would be a number between 0 and 100.

>>
>> If you have a list of numbers that you would like to make permutations
>> of, std::next_permutation() will do the job for you. If you want to
>> count up every X from 0 to 100 you'll have to do that yourself, but it's
>> easy.

Thore, you're mean.

>That is not it. Not all numbers from 1 to 100 could be used in a group of
>10 x's. And Numbers could be repeated in the group of 10's. I need all
>combinations. And there are to many to find by hand, plus to do it by hand
>would end up being very confusing after a while. This is not just a count
>up of loops or what else. It is a lot more complicated than that.

Have you considered, as Buster Copley did for you, the number of
combinations?

It may be that he misunderstood you, but the spirit of the argument
was sound; the list will be _long_, and it's generated by simple
counting (in the decimal system if you have ten unique values).

>PS. TO BUSTER COPLEY - I don't bullsh** on my posts . It is a personal
>interest project. And I have worked on it for about 5 hours. Thank You.

It seems impossible that you worked on it for even 1 minute.

Anyway, it doesn't have much to do with C++.

So replies to this posting are redirected to [comp.programming], which
I think is where you should have posted your problem in the first
place.

Hth.

XFUT: [comp.programming].

Buster Copley
Guest
Posts: n/a

 09-25-2003
Enjoy!

#include <iostream>
#include <vector>

typedef std::vector <int>::size_type sz_t;
typedef unsigned digit_t;

const sz_t size = 10;
const digit_t modulus = 101;

std:stream &
operator << (std:stream & s, const std::vector <digit_t> & v)
{
for (sz_t i = 0, n = v.size (); i != n; ++ i)
(i ? (s << ", ") : s) << v [i];
return s;
}

int main ()
{
std::vector <digit_t> v (size);
while (v.back () != modulus)
{
std::cout << v << '\n';
++ v.front ();
for (sz_t i = 0; i != size - 1; ++ i) if (v [i] == modulus)
{
v [i] = 0;
++ v [i + 1];
}
}
}

Sam Holden
Guest
Posts: n/a

 09-25-2003
On Thu, 25 Sep 2003 02:50:43 GMT, Roger B. <(E-Mail Removed)> wrote:
> That is not it. Not all numbers from 1 to 100 could be used in a group of
> 10 x's. And Numbers could be repeated in the group of 10's. I need all
> combinations. And there are to many to find by hand, plus to do it by hand
> would end up being very confusing after a while. This is not just a count
> up of loops or what else. It is a lot more complicated than that.

You make no sense. The suggested solution is the normal way to
generate permutations and combinations. Writing code to do it
instead of a pen and paper is trivial enough.

--
Sam Holden

Thore B. Karlsen
Guest
Posts: n/a

 09-25-2003
On Thu, 25 Sep 2003 02:50:43 GMT, "Roger B." <(E-Mail Removed)>
wrote:

>That is not it. Not all numbers from 1 to 100 could be used in a group of
>10 x's. And Numbers could be repeated in the group of 10's. I need all
>combinations. And there are to many to find by hand, plus to do it by hand
>would end up being very confusing after a while. This is not just a count
>up of loops or what else. It is a lot more complicated than that.

I honestly don't know what you're looking for. Do you want to do:

0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,1
0,0,0,0,0,0,0,0,0,2

etc.

0,1,2,3,4,5,6,7,8,9

and generate all the combinations of those given numbers.

The first case is very easy to code, but will take a lifetime to finish
if you want to go through all of them. For the second case, use
std::next_permutation().

--
Be seeing you.

Gavin Deane
Guest
Posts: n/a

 09-25-2003
"Roger B." <(E-Mail Removed)> wrote in message news:<7Kscb.575053\$uu5.94602@sccrnsc04>...

<please don't top-post, thank you - rearranged>

> > On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <(E-Mail Removed)>
> > wrote:
> >
> > >Hello,
> > >
> > > I am working on a personal interest project and have been racking my

> brain
> > >on this problem for about 5 hours total now, and tracking through old
> > >newsgroup posts but haven't figuried it out yet so heres my question.
> > >
> > >I want to be able to make a list of all possible combinations (repitiions
> > >are allowed) of numbers where X is a arbitrary initeger between something
> > >like 0 and 100
> > >and the number of x's is arbitrary as well in this example 10 x's are
> > >present.
> > >
> > >x,x,x,x,x,x,x,x,x,x
> > >
> > >I want to find all possible combinations for this. In the end I would

> have
> > >a list of all possible combinations of the x's in groups of ten whre each

> x
> > >would be a number between 0 and 100.

> >
> > If you have a list of numbers that you would like to make permutations
> > of, std::next_permutation() will do the job for you. If you want to
> > count up every X from 0 to 100 you'll have to do that yourself, but it's
> > easy.

>
> That is not it. Not all numbers from 1 to 100 could be used in a group of
> 10 x's. And Numbers could be repeated in the group of 10's. I need all
> combinations. And there are to many to find by hand, plus to do it by hand
> would end up being very confusing after a while. This is not just a count
> up of loops or what else. It is a lot more complicated than that.

I'm still not sure of the question. Is what Buster Copley posted not
what you're after? Before writing any C++ code, you will need to
precisely and fully understand how you would solve the problem on
paper, given enough time. If you've got that far, have you got any
code you're having problems with?

The standard advice is to break the problem into simple steps and
implement them one at a time. Without understanding the problem it's
difficult to try and suggest where to start.

GJD

Jerry Coffin
Guest
Posts: n/a

 09-25-2003
In article <ELrcb.568905\$Ho3.104820@sccrnsc03>, http://www.velocityreviews.com/forums/(E-Mail Removed)
says...
> Hello,
>
> I am working on a personal interest project and have been racking my brain
> on this problem for about 5 hours total now, and tracking through old
> newsgroup posts but haven't figuried it out yet so heres my question.
>
> I want to be able to make a list of all possible combinations (repitiions
> are allowed) of numbers where X is a arbitrary initeger between something
> like 0 and 100
> and the number of x's is arbitrary as well in this example 10 x's are
> present.
>
> x,x,x,x,x,x,x,x,x,x
>
> I want to find all possible combinations for this. In the end I would have
> a list of all possible combinations of the x's in groups of ten whre each x
> would be a number between 0 and 100.

Try a different approach. Storage alone for this is prohibitive for any
practical purpose -- if you stored your list formatted as you've shown
it above (i.e. numbers converted to text, commas in between them) you're
looking at approximately 3 terabytes of storage. If you store the data
in a fairly obvious binary form, you can get that down to roughly 1
terabyte, but even that's still ridiculous.

Thus the advice to find a different approach -- this one is a problem,
not a solution.

--
Later,
Jerry.

The universe is a figment of its own imagination.