473,401 Members | 2,146 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,401 software developers and data experts.

STL & Generating exponents, permutations, arrangements, and combinations

Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?

--
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html

Jul 22 '05 #1
2 2825
"Alex Vinokur" <al****@big.foot.com> writes:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?


exponents?

Here's a quickie example of permutations that I had lying around. See the
doc for details.

#include <vector> //for vector
#include <functional> //for less
#include <iostream>
using namespace std;
int main()
{
char a2[] = "abcdefghij";
vector<char> m2(a2, a2+10);
vector<char> next_m2((size_t)10);

next_m2=m2;
next_permutation(next_m2.begin(),
next_m2.end(),less<int>());

cout << "Original values: ";
copy(m2.begin(),m2.end(),
ostream_iterator<char>(cout," "));
cout << endl;

cout << "Next Permutation: ";
copy(next_m2.begin(),next_m2.end(),
ostream_iterator<char>(cout," "));
cout << endl << endl;

return 0;
}
Jul 22 '05 #2

"Tim Love" <tp*@eng.cam.ac.uk> wrote in message news:c7**********@pegasus.csx.cam.ac.uk...
"Alex Vinokur" <al****@big.foot.com> writes:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?


exponents?

[snip]

See http://www.saliu.com/permutations.html
-------------------------------------------------
An example of exponents (N=3, M=3): 111,112,113,121,122,123,131,132, etc. (a total of 27 sets).
An example of permutations (for N = 3): 1 2 3, 1 3 2, 2 1 3, 2 3 1, 3 1 2, 3 2 1.
An example of arrangements (for N = 3, M = 2): 1 2, 1 3, 2 1, 2 3, 3 1, 3 2.
An example of combinations (for N = 3, M = 2): 1 2, 1 3, 2 3.
-------------------------------------------------

--
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html

Jul 22 '05 #3

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...
0
by: Alex Vinokur | last post by:
C++ program for generating combinatorial objects (exponents, permutations, arrangements, combinations for any numbers and words) can be downloaded at...
4
by: pauljwilliams | last post by:
Hi there, I'm looking for an algorithm that will generate combinations in the following way: Given a lower bound, and an upper bound, generate a set of size n containing all combinates of...
8
by: Mir Nazim | last post by:
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible...
0
by: JosAH | last post by:
Greetings, last week I stated that a lot of topics in a lot of forums mention all sorts of sorting problems. Last week's tip gave an answer to quite a bit of those sorting problems. Another...
6
by: py_genetic | last post by:
Hi, I'm looking to generate x alphabetic strings in a list size x. This is exactly the same output that the unix command "split" generates as default file name output when splitting large...
10
by: henryrhenryr | last post by:
Hi here's a test of logic for mathmeticians (I do have an actual use for this too...) I need to split a 4 or 5 word phrase into all possible combinations of the individual words: eg: 4...
14
by: bjorklund.emil | last post by:
Hello pythonistas. I'm a newbie to pretty much both programming and Python. I have a task that involves writing a test script for every possible combination of preference settings for a software...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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...
0
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,...
0
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...

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.