Fairfield
asked on
determine all possible combinations of string
I am trying to determine all of the possible combinations of all alpha-numerics with the following format xxxxxx-xxx where x can be any alpha numberic. Can someone please help with this?
The count, or the actual values?
ASKER
Well, if I can get the actual values, that would be great.
Well the count of possible values would be: 36^9 = 101,559,956,668,416.
Yeah. And I don't think EE will let us post that long of a string ;)
ASKER
Does someone have some code that would generate this in a file?
Do you really want to generate them or be able to search for that pattern or what?
Actually, it would be even larger if you are going case-insensitive and allowing upper- and lower-case.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's another example:
//////////////////////////////////////////////////////////////////////
//
// Compile options needed: /GX
//
// next_permutation.cpp : Illustrates how to use the
// next_permutation function.
//
// Functions:
//
// next_permutation : Change the order of the sequence to the
// next lexicograhic permutation.
//////////////////////////////////////////////////////////////////////
// disable warning C4786: symbol greater than 255 character,
// okay to ignore
#pragma warning(disable: 4786)
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdlib.h>
#include <search.h>
using namespace std ;
// Define a template class vector of strings
typedef vector<string> StrVector ;
//Define an iterator for template class vector of strings
typedef StrVector::iterator StrVectorIt ;
//Define an ostream iterator for strings
typedef ostream_iterator<string> StrOstreamIt;
void Permutate(char *pattern);
//int compare((const void *) arg1, (void *)arg2));
void main()
{
Permutate("ABC"); // Replace with your pattern
}
void Permutate(char *pattern)
{
int len = strlen(pattern);
StrVector Pattern(len) ;
StrVectorIt start, end, it ;
StrOstreamIt outIt(cout, " ") ;
start = Pattern.begin() ; // location of first element of Pattern
end = Pattern.end() ; // one past the location last element of Pattern
// Initialize vector Pattern
for (int i = 0; i < len; i++)
Pattern[i] = pattern[i];
// print content of Pattern
cout << "Before calling next_permutation...\n" << "Pattern: " ;
for(it = start; it != end; it++)
cout << *it << " " ;
cout << "\n\n" ;
// Generate all possible permutations
cout << "After calling next_permutation...." << endl ;
while (next_permutation(start, end))
{
copy(start, end, outIt);
cout << endl;
}
}