# algorithm problem in sofware project

hey dudes
we're in a middle of a software project, and we got stuck somewhere. in this part we should do something like this:
1. get a rule that looks like !0-4?2-4@@ that defines a password structure, and a dictionary filename
2. break the rule into parts, !0-4 ?2-4
each part represents an other rule- let's say !0-4 means the first part of the password should contain between 0 and 4 english chars, ?2-4 means that the second part should contain between 2 and 4 general chars (including %,^ etc), and @ means that we receive a word from a dictionary, so let's say the dictionary has the words "abc" and "asd", a good password (that fits in the rule) is alpha%&abcasd, because we can divide it into alph a%& abc asd and it fits the rule.
3. we get an int n (and here's the hard part), we want to generate the n'th password, so that for different n's we'll get different results. in other words, there is a 1 to 1 correspondence between the n's and the passwords generated by the rule.
the problem is that we can get rules like !0-2!0-2, and then the password aa can be generated in 3 different ways- (aa)(), ()(aa), (a)(a). this ofc gets even more complex for longer and more complex rules.

i'd be glad if someone could help us out here...we're really stuck :

• 1. Can you designate a special character as "non-password"? If you could, then you could insert between elements in your password for uniqueness. Like, if * was non-password, then your example becomes
aa (or aa*), a*a, aa (or *aa, one of them has to have a star).

2. Can you programmatically restrict possible sequences of password keys? If you could do that, then you wouldn't have to worry about !0-2!0-2 coming up because, per your new definition, it doesn't form a valid password.

3. I suppose you could say that, for every character, it has a "follow" character. If you generate some character A as the middle part of a rule, and B is A's follow character, then B cannot come after A. However, if you generate A at the end of a rule, B must be the first character in A. Then, every time you see a follow character, you know you have started a new word. I don't know the full rule scheme you are working with, but it stands to reason that some characters might need more than one follow character. Also, it lowers the security of your passwords.