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? | | | | re: Permutations of a set
John Trunek wrote:[color=blue]
> 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?[/color]
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. | | | | re: Permutations of a set
John Trunek wrote:[color=blue]
> 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?[/color]
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. | | | | re: Permutations of a set
Buster wrote:
[color=blue]
> John Trunek wrote:
>[color=green]
>> 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?[/color]
>
> 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).[/color]
s/images of permutations/permutations of images/
[color=blue]
> 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.
>[/color]
--
Regards,
Buster. | | | | re: Permutations of a set
Buster wrote:
[color=blue]
> John Trunek wrote:
>[color=green]
>> 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?[/color]
>
> 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).[/color]
s/images of permutations/permutations of images/
[color=blue]
> 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.
>[/color]
--
Regards,
Buster. | | | | re: Permutations of a set
Buster wrote:
[color=blue]
> Buster wrote:
>[color=green]
>> John Trunek wrote:
>>[color=darkred]
>>> 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?[/color]
>>
>>
>> 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).[/color]
>
> s/images of permutations/permutations of images/[/color]
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'.
[color=blue][color=green]
>> 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.
>>[/color]
>[/color]
--
Regards,
Buster. | | | | re: Permutations of a set
Buster wrote:
[color=blue]
> Buster wrote:
>[color=green]
>> John Trunek wrote:
>>[color=darkred]
>>> 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?[/color]
>>
>>
>> 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).[/color]
>
> s/images of permutations/permutations of images/[/color]
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'.
[color=blue][color=green]
>> 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.
>>[/color]
>[/color]
--
Regards,
Buster. | | | | re: Permutations of a set
* Buster <noone@nowhere.com> schriebt:[color=blue]
> John Trunek wrote:[color=green]
> > 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?[/color]
>
> 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).[/color]
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.
[color=blue]
> 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.[/color]
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? | | | | re: Permutations of a set
* Buster <noone@nowhere.com> schriebt:[color=blue]
> John Trunek wrote:[color=green]
> > 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?[/color]
>
> 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).[/color]
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.
[color=blue]
> 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.[/color]
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? | | | | re: Permutations of a set
Alf P. Steinbach wrote:
[color=blue]
> * Buster <noone@nowhere.com> schriebt:
>[color=green]
>>John Trunek wrote:
>>[color=darkred]
>>>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?[/color]
>>
>>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).[/color]
>
> 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.[/color]
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"?)
[color=blue][color=green]
>>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.[/color]
>
> 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.[/color]
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. | | | | re: Permutations of a set
Alf P. Steinbach wrote:
[color=blue]
> * Buster <noone@nowhere.com> schriebt:
>[color=green]
>>John Trunek wrote:
>>[color=darkred]
>>>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?[/color]
>>
>>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).[/color]
>
> 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.[/color]
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"?)
[color=blue][color=green]
>>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.[/color]
>
> 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.[/color]
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. | | | | re: Permutations of a set
John Trunek wrote:
[color=blue]
> 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?[/color]
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 | | | | re: Permutations of a set
John Trunek wrote:
[color=blue]
> 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?[/color]
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 | | | | re: Permutations of a set
* Buster <noone@nowhere.com> schriebt:[color=blue]
>
> 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);'.[/color]
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? | | | | re: Permutations of a set
* Buster <noone@nowhere.com> schriebt:[color=blue]
>
> 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);'.[/color]
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? | | | | re: Permutations of a set
* "Steven T. Hatton" <susudata@setidava.kushan.aa> schriebt:[color=blue]
> John Trunek wrote:
>[color=green]
> > 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?[/color]
>
> If permutations is what you really want, it's actually quite easy. In a
> word, /recursion/.[/color]
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? | | | | re: Permutations of a set
* "Steven T. Hatton" <susudata@setidava.kushan.aa> schriebt:[color=blue]
> John Trunek wrote:
>[color=green]
> > 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?[/color]
>
> If permutations is what you really want, it's actually quite easy. In a
> word, /recursion/.[/color]
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? | | | | re: Permutations of a set alfps@start.no (Alf P. Steinbach) wrote in
news:407223b6.342029140@news.individual.net:
[color=blue]
> * Buster <noone@nowhere.com> schriebt:[color=green]
>>
>> 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);'.[/color]
>
> 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.[/color]
Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words AFAIK.
:) | | | | re: Permutations of a set alfps@start.no (Alf P. Steinbach) wrote in
news:407223b6.342029140@news.individual.net:
[color=blue]
> * Buster <noone@nowhere.com> schriebt:[color=green]
>>
>> 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);'.[/color]
>
> 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.[/color]
Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words AFAIK.
:) | | | | re: Permutations of a set
bartek wrote:
[color=blue][color=green]
>> 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.[/color]
>
> Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words
> AFAIK.
> :)[/color]
Some (hopefully many) systems will at least warn you that your password
is too trivial, so your examples might not be seen that often. | | | | re: Permutations of a set
bartek wrote:
[color=blue][color=green]
>> 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.[/color]
>
> Not necessarily... 'qwerty' 'asdfg' and '1234' are not English words
> AFAIK.
> :)[/color]
Some (hopefully many) systems will at least warn you that your password
is too trivial, so your examples might not be seen that often. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,223 network members.
|