473,320 Members | 1,839 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,320 software developers and data experts.

Permutations of a set

I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?
Jul 22 '05 #1
20 1438
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?


Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).

You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.

--
Regards,
Buster.
Jul 22 '05 #2
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?


Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).

You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.

--
Regards,
Buster.
Jul 22 '05 #3
Buster wrote:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?
Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


s/images of permutations/permutations of images/
You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


--
Regards,
Buster.
Jul 22 '05 #4
Buster wrote:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?
Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


s/images of permutations/permutations of images/
You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


--
Regards,
Buster.
Jul 22 '05 #5

Buster wrote:
Buster wrote:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?

Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


s/images of permutations/permutations of images/


No, sorry, let it stand. I meant the images of the permutations,
viewing the permutations as functions, as I said. To be clear, these
sets, the images of the permutations of a set T (say), are what might
be called the 'results of permuting T', or just 'the permutations of T',
speaking less formally.

Another obscurity is the meaning of the word 'set' in this context.
The OP may have been referring to the standard library's 'set' class
template, as well as alluding to the set-theoretic term 'set'.
You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


--
Regards,
Buster.
Jul 22 '05 #6

Buster wrote:
Buster wrote:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?

Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


s/images of permutations/permutations of images/


No, sorry, let it stand. I meant the images of the permutations,
viewing the permutations as functions, as I said. To be clear, these
sets, the images of the permutations of a set T (say), are what might
be called the 'results of permuting T', or just 'the permutations of T',
speaking less formally.

Another obscurity is the meaning of the word 'set' in this context.
The OP may have been referring to the standard library's 'set' class
template, as well as alluding to the set-theoretic term 'set'.
You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


--
Regards,
Buster.
Jul 22 '05 #7
* Buster <no***@nowhere.com> schriebt:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?
Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


I think it's more reasonable to assume that the OP wants to generate all
possible passwords of length Y from some character set with X characters.
In which case it's combinations, not permutations. I think.

You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


If assumption above is correct then the easiest is probably to just
count up; but the easiest programmatically will not be very efficient
in light of some combinations being far more probable than others.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #8
* Buster <no***@nowhere.com> schriebt:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?
Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


I think it's more reasonable to assume that the OP wants to generate all
possible passwords of length Y from some character set with X characters.
In which case it's combinations, not permutations. I think.

You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


If assumption above is correct then the easiest is probably to just
count up; but the easiest programmatically will not be very efficient
in light of some combinations being far more probable than others.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #9
Alf P. Steinbach wrote:
* Buster <no***@nowhere.com> schriebt:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?


Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


I think it's more reasonable to assume that the OP wants to generate all
possible passwords of length Y from some character set with X characters.
In which case it's combinations, not permutations. I think.


The original post doesn't suggest that to me. Looks like we'll need a
clarification. (I don't quite follow your suggestion either. Is "xyz"
the same password as "zyx"?)
You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


If assumption above is correct then the easiest is probably to just
count up; but the easiest programmatically will not be very efficient
in light of some combinations being far more probable than others.


All passwords of length Y from a character set with X characters are
equally 'probable' (think 'lottery'). In the obvious thought experiment,
each distinct password has probability 'std::pow (X, -Y);'.

--
Regards,
Buster.
Jul 22 '05 #10
Alf P. Steinbach wrote:
* Buster <no***@nowhere.com> schriebt:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?


Your terminology is non-standard (and I'm not talking about the C++
standard). A permutation of a set S is a bijective map from S to S.
My guess is that you want the set of images of permutations of Y-
subsets of S (where S is your set of X items, and where a 'Y-subset'
of S is a subset of S which has Y elements).


I think it's more reasonable to assume that the OP wants to generate all
possible passwords of length Y from some character set with X characters.
In which case it's combinations, not permutations. I think.


The original post doesn't suggest that to me. Looks like we'll need a
clarification. (I don't quite follow your suggestion either. Is "xyz"
the same password as "zyx"?)
You need to write your own function for this. It will be easiest
to make the function recursive, at least to begin with, I think.
Post your attempt here and I'm sure you will get help.


If assumption above is correct then the easiest is probably to just
count up; but the easiest programmatically will not be very efficient
in light of some combinations being far more probable than others.


All passwords of length Y from a character set with X characters are
equally 'probable' (think 'lottery'). In the obvious thought experiment,
each distinct password has probability 'std::pow (X, -Y);'.

--
Regards,
Buster.
Jul 22 '05 #11
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?

If permutations is what you really want, it's actually quite easy. In a
word, /recursion/.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #12
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?

If permutations is what you really want, it's actually quite easy. In a
word, /recursion/.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #13
* Buster <no***@nowhere.com> schriebt:

All passwords of length Y from a character set with X characters are
equally 'probable' (think 'lottery'). In the obvious thought experiment,
each distinct password has probability 'std::pow (X, -Y);'.


That turns out not to be the case. Some passwords are used far more often
than others. In particular, passwords that contain English words are used
extremely more often than those that do not.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #14
* Buster <no***@nowhere.com> schriebt:

All passwords of length Y from a character set with X characters are
equally 'probable' (think 'lottery'). In the obvious thought experiment,
each distinct password has probability 'std::pow (X, -Y);'.


That turns out not to be the case. Some passwords are used far more often
than others. In particular, passwords that contain English words are used
extremely more often than those that do not.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #15
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?


If permutations is what you really want, it's actually quite easy. In a
word, /recursion/.


You can also enumerate permutations using the factorial number system
plus a bitset.

I once had a letter to the editor about that printed in Computer Language,
the now defunct magazine infamous for its shameless promotion of Jolt Cola.

The editors added the heading (after earlier discussions of Knuth's two
fundamental ways of generating permutations) "The third way is the charm".

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #16
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
John Trunek wrote:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either through the
STL or some other library to do this, or do I need to write my own
code?


If permutations is what you really want, it's actually quite easy. In a
word, /recursion/.


You can also enumerate permutations using the factorial number system
plus a bitset.

I once had a letter to the editor about that printed in Computer Language,
the now defunct magazine infamous for its shameless promotion of Jolt Cola.

The editors added the heading (after earlier discussions of Knuth's two
fundamental ways of generating permutations) "The third way is the charm".

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #17
al***@start.no (Alf P. Steinbach) wrote in
news:40****************@news.individual.net:
* Buster <no***@nowhere.com> schriebt:

All passwords of length Y from a character set with X characters are
equally 'probable' (think 'lottery'). In the obvious thought
experiment, each distinct password has probability 'std::pow (X,
-Y);'.


That turns out not to be the case. Some passwords are used far more
often than others. In particular, passwords that contain English
words are used extremely more often than those that do not.


Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words AFAIK.
:)
Jul 22 '05 #18
al***@start.no (Alf P. Steinbach) wrote in
news:40****************@news.individual.net:
* Buster <no***@nowhere.com> schriebt:

All passwords of length Y from a character set with X characters are
equally 'probable' (think 'lottery'). In the obvious thought
experiment, each distinct password has probability 'std::pow (X,
-Y);'.


That turns out not to be the case. Some passwords are used far more
often than others. In particular, passwords that contain English
words are used extremely more often than those that do not.


Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words AFAIK.
:)
Jul 22 '05 #19
bartek wrote:
That turns out not to be the case. Some passwords are used far more
often than others. In particular, passwords that contain English
words are used extremely more often than those that do not.


Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words
AFAIK.
:)


Some (hopefully many) systems will at least warn you that your password
is too trivial, so your examples might not be seen that often.

Jul 22 '05 #20
bartek wrote:
That turns out not to be the case. Some passwords are used far more
often than others. In particular, passwords that contain English
words are used extremely more often than those that do not.


Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words
AFAIK.
:)


Some (hopefully many) systems will at least warn you that your password
is too trivial, so your examples might not be seen that often.

Jul 22 '05 #21

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

Similar topics

10
by: Steve Goldman | last post by:
Hi, I am trying to come up with a way to develop all n-length permutations of a given list of values. The short function below seems to work, but I can't help thinking there's a better way. ...
20
by: John Trunek | last post by:
I have a set of X items, but want permutations of length Y (X > Y). I am aware of the permutation functions in <algorithm>, but I don't believe this will do what I want. Is there a way, either...
2
by: Alex Vinokur | last post by:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any numbers and words? -- Alex Vinokur mailto:alexvn@connect.to...
11
by: Girish Sahani | last post by:
Hi guys, I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) def permute(string): l= l.append(string) string1 = '' for i in...
20
by: anurag | last post by:
hey can anyone help me in writing a code in c (function) that prints all permutations of a string.please help
7
by: Christian Meesters | last post by:
Hi, I'd like to hack a function which returns all possible permutations as lists (or tuples) of two from a given list. So far, I came up with this solution, but it turned out to be too slow for...
1
by: JosAH | last post by:
Greetings, last week we talked a bit about generating permutations and I told you that this week will be about combinations. Not true; there's a bit more to tell about permutations and that's...
5
by: Shraddha | last post by:
Suppose we are having 3 variables...a,b,c And we want to print the permutations of these variables...Such as...abc,acb,bca...all 6 of them... But we are not supposed to do it mannually... I...
2
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the...
82
by: Bill Cunningham | last post by:
I don't know if I'll need pointers for this or not. I wants numbers 10^16. Like a credit card 16 digits of possible 10 numbers, so I guess that would be 10^16. So I have int num ; These are of...
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...
1
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.