in reply to Re^2: Generating combinatorial strings
in thread Generating combinatorial strings

You might still use one of the algorithms proposed in the previous thread. However you need to add an additional check on validity (e.g. don't use the value if the second digit is a 3).
HTH, Rata