Skip to content

Instantly share code, notes, and snippets.

@9b
Last active August 29, 2015 13:55
Show Gist options
  • Save 9b/8694390 to your computer and use it in GitHub Desktop.
Save 9b/8694390 to your computer and use it in GitHub Desktop.
#include <sstream>
#include <string>
#include <cstring>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int i, j, k, glob;
char alpha[] = "abcdefghijklmnopqrstuvwxyz1234567890";
int size;
int aSize = strlen(alpha);
string bucket[100000];
stringstream ss;
for (i = 0; i < aSize - 1; i++) {
/* printf("%c\n", alpha[i]); */
ss << alpha[i];
/* cout << ss.str() << endl; */
bucket[glob] = ss.str();
++glob;
ss.str("");
for (j = 0; j < aSize; j++) {
/* printf("%c%c\n", alpha[i], alpha[j]); */
ss << alpha[i] << alpha[j];
/* cout << ss.str() << endl; */
bucket[glob] = ss.str();
++glob;
ss.str("");
for (k = 0; k < aSize; k++) {
/* printf("%c%c%c\n", alpha[i], alpha[j], alpha[k]); */
ss << alpha[i] << alpha[j] << alpha[k];
/* cout << ss.str() << endl; */
bucket[glob] = ss.str();
++glob;
ss.str("");
}
}
}
cout << glob << endl;
/*
size = sizeof(bucket) / sizeof(bucket[0]);
for (i = 0; i < size; i++) {
cout << bucket[i] << endl;
}
*/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment