Well, at least about the a-e you're right; the range a-m for the second letter is only valid if the first letter actually is a, otherwise it's smaller, of course (a-j if the first letter is b, etc).
I haven't yet thought of an algorithm to count or generate the other possibilities. (Oh, wait a minute, something just comes to my mind while writing this: this is somewhat similar to a number system with radix mult (which is 3 in this case). The catch is that there are more distinct digits than the radix, which causes the multiple solutions.)
I hope you can do something with this information, but I think I should really get some sleep now... |