473,387 Members | 1,582 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,387 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 2251
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.