473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
20 2301
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 programmaticall y 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******@setid ava.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******@setid ava.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.i ndividual.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.i ndividual.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

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

Similar topics

10
5683
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. Not being a computer scientist, I find recursive functions to be frightening and unnatural. I'd appreciate if anyone can tell me the pythonic idiom to accomplish this. Thanks for your help,
20
1470
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 through the STL or some other library to do this, or do I need to write my own code?
11
5928
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 range(0,len(string)-1,1): string1 = string + string
20
41311
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
2512
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 the given problem, because the list passed ("atomlist") can be some 1e5 items long: def permute(atomlist, size = 2): """ returns a list of atoms grouped by two
1
10936
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 what this Tip Of The Week is about. Maybe later we'll talk a bit about combinations (if anyone's interested). The little utility class we implemented last week was able to generate a next permutation (if any) given a current permutation. But what...
5
2696
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 want to know that formula by which this can be possible... Then that program will be ok for nnumber of variables.... Can anyone help me for that?
2
5901
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 dictionary essentially creates the following array: Key Value
82
3712
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 course declared and not initialized. Now I want to initialize them all with '\0'. That I'm guessing would involve while ( --). Or maybe for. Would pointers be involved in this? With this excercise I would learn working with multi-dimensional
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.