473,326 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Permutation lists?? Really Need Help

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.
Jul 19 '05 #1
13 2100
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.

Jul 19 '05 #2
On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <ro*******@hotmail.com>
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.
Jul 19 '05 #3
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" <si*@6581.com> wrote in message
news:g5********************************@4ax.com...
On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <ro*******@hotmail.com>
wrote:
Hello,

I am working on a personal interest project and have been racking my brainon 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 havea list of all possible combinations of the x's in groups of ten whre each xwould 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.

Jul 19 '05 #4
[Please do not (repeated for your convenience, DO NOT) top-post, rearranged:]

On Thu, 25 Sep 2003 02:50:43 GMT, "Roger B." <ro*******@hotmail.com> wrote:
"Thore B. Karlsen" <si*@6581.com> wrote in message
news:g5********************************@4ax.com.. .
On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <ro*******@hotmail.com>
wrote:
>Hello,
>
> I am working on a personal interest project and have been racking mybrain >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 wouldhave >a list of all possible combinations of the x's in groups of ten whre eachx >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].

Jul 19 '05 #5
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::ostream &
operator << (std::ostream & 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];
}
}
}

Jul 19 '05 #6
On Thu, 25 Sep 2003 02:50:43 GMT, Roger B. <ro*******@hotmail.com> 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

Jul 19 '05 #7
On Thu, 25 Sep 2003 02:50:43 GMT, "Roger B." <ro*******@hotmail.com>
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.

Or do you want to start with a list like this:

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.
Jul 19 '05 #8
"Roger B." <ro*******@hotmail.com> 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." <ro*******@hotmail.com>
wrote:
Hello,

I am working on a personal interest project and have been racking my brainon 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 havea list of all possible combinations of the x's in groups of ten whre each xwould 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
Jul 19 '05 #9
In article <ELrcb.568905$Ho3.104820@sccrnsc03>, ro*******@hotmail.com
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.
Jul 19 '05 #10


"Roger B." wrote:

That is not it. Not all numbers from 1 to 100 could be used in a group of
10 x's.
Why not?
And Numbers could be repeated in the group of 10's.
Good.
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.
Sure, that's why a computer is perfect for this. But nevertheless (maybe
using smaller numbers), doing it by hand gives a good grasp at what the
program is supposed to do.
This is not just a count
up of loops or what else.
Basically: Yes it is. But how the loops look in specific and/or if
maybe recursion is part of your soultion can only be decided if we
understand your requirement.
It is a lot more complicated than that.


I'm sure it is not complicated.
The problem is, that nobody seems to understand your requirement
completely. Thus we don't know what to suggest.

Could you try to rephrase it?
Also make sure we understand what is variable in your assignment
and what is constant. As said: Choose smaller numbers and show
an example. That helps a lot in understanding your problem.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 19 '05 #11
"Roger B." <ro*******@hotmail.com> wrote in message news:<ELrcb.568905$Ho3.104820@sccrnsc03>...
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.

This will work. However, don't wait up all night for the output.
Were you to save this to a file, it would fill up a world's worth of
hard-drives!!!

#include <iostream>
#include <fstream>

using namespace std;

int main(){
int a,b,c,d,e,f,g,h,i,j;
int max = 100;
for(a=0;a<max;++a){
for(b=0;b<max;++b){
for(c=0;c<max;++c){
for(d=0;d<max;++d){
for(e=0;e<max;++e){
for(f=0;f<max;++f){
for(g=0;g<max;++g){
for(h=0;h<max;++h){
for(i=0;i<max;++i){
for(j=0;j<max;++j){
cout <<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "
<<f<<" "<<g<<" "<<h<<" "<<i<<" "<<j<<endl;
}}}}}}}}}}
}
Jul 19 '05 #12
<Roger B>
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 still don't understand it. Is it the famous lion-cage in disguise? You have,
say, 100 cages and 10 fierce lions. Each lion must have a cage on its own.
How many ways are there to cage the lions? Is that the question? What do
you try to solve? Write out 10 lines by hand so that I can see what you're
after.

-X
Jul 19 '05 #13

"Roger B." <ro*******@hotmail.com> wrote in message
news:ELrcb.568905$Ho3.104820@sccrnsc03...
[snip]
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


are you thinking of (pared down example, five numbers two at a time)?
1,1 2,2 3,3 4,4 5,5
1,2 2,3 3,4 4,5
1,3 2,4 3,5
1,4 2,4
1,5

Are you thinking along the line where order does not matter. 3 is only
paired with 5 once.
Are you trying to generate this sequence, or predict the predict the
number of unique
combinations?

/*MAJOR clue here, Note that the number on the right is always equal
to or greater than
the number on the left. This makes 3, 5 legal but not 5, 3*/

if you just want to count them... n =Number of numbers, k =How many in
each group

(n + k - 1)!
-----------
k! * (n- 1)!

Jul 19 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Talin | last post by:
I'm sure I am not the first person to do this, but I wanted to share this: a generator which returns all permutations of a list: def permute( lst ): if len( lst ) == 1: yield lst else: head =...
41
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and...
3
by: Jack Middleton | last post by:
Hi! I'm lookin for a faster permutation algorithm for matrices. I know that it can be done with multiplying a matrix with a permutation matrix. It just seems a waste to iterate through all those...
1
by: user | last post by:
Hello I have Array of 50 ints. I want to receive random permutation, so in each int will be different number from 0-49. Is there any class for permutation ? Thanx Michal
6
by: Rajesh | last post by:
Hello Everybody, Can anybody help me in writing a C program to generate and print all possible combinations of n numbers. For eg. for 3 numbers(1,2,3) there turn out 3! combinations. (1,2,3),...
27
by: onkar | last post by:
How to generate different permutations of n char array? ex : for n= 3, and basic string = abc bca cab bac cab ..... ... ..
6
by: fool | last post by:
Dear group, Given a string I have to print the permutation, using some looping tricks. This is not a Home work problem. My best try as beginner is: #include<stdio.h> #include<stdlib.h> ...
6
by: badcrusher10 | last post by:
Hello. I'm having trouble figuring out what to do and how to do.. could someone explain to me what I need to do in order to work? THIS IS WHAT I NEED TO DO: Professor Snoop wants a program...
7
by: xirowei | last post by:
Let's say i create a String array that store 4 Alphabets {"A","B","C","D"} How can i get the result if i need permutation of 4P3 and 4P2? I had refer to many examples from the internet, but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.