Code:
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>
std::deque<std::string> aset;
unsigned lookup(std::string in)
{
for (unsigned i = 0; i < 720; i++)
if (aset[i] == in) return i;
}
void printPermutation(int x, int y, int z)
{
std::cout << aset[x] << "," << aset[y] << ","<< aset[z] << std::endl;
}
void printPermutation(unsigned ordinal)
{
int x,y,z;
x= ordinal/518400;
ordinal-=(x*518400);
y = ordinal/720;
ordinal-=(y*720);
z = ordinal;
printPermutation(x,y,ordinal);
}
void printXYZ(std::string a, std::string b, std::string c)
{
std::cout << lookup(a) << "," << lookup(b) << ","<< lookup(c) << std::endl;
}
void printOrdinal(std::string a, std::string b, std::string c)
{
std::cout << lookup(a)*518400+ lookup(b)*720+lookup(c) << std::endl;
}
int main()
{
std::string val = "123456";
aset.push_back(val);
while(std::next_permutation(val.begin(),val.end())) aset.push_back(val);
std::cout << aset.size() << std::endl ; //just to show it create 720 permutations
printPermutation(3, 10, 650);
printPermutation(3057652);
printXYZ("156423","354216","615342");
printOrdinal("156423","354216","615342");
}