Skip to content

Instantly share code, notes, and snippets.

@Kobold
Created August 31, 2010 20:12
Show Gist options
  • Save Kobold/559660 to your computer and use it in GitHub Desktop.
Save Kobold/559660 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<char, char> alternatives;
void traverse(string prefix, string rest)
{
if (rest.empty()) {
cout << prefix << endl;
return;
}
char first = rest[0];
string end = rest.substr(1);
traverse(prefix + first, end);
if (alternatives.find(first) != alternatives.end()) {
traverse(prefix + alternatives[first], end);
}
}
int main(int argc, char const *argv[])
{
alternatives['s'] = '$';
alternatives['t'] = '+';
alternatives['l'] = '|';
alternatives['o'] = '0';
alternatives['e'] = '3';
alternatives['a'] = '@';
alternatives['v'] = '^';
traverse(string(""), string("bonoboape"));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment