This program generates sequences of tokens that conform to a set of rules you specify as regular expressions. Try it first with no rules, to see the way the raw sequences are generated. It should be: 1111 1112 1113 1114 1121 etc. Then use the following rule to eliminate sequences with repeated digits: ![1-] The result should be 1234 1243 1324 1423 1432 2134 etc. Now add further rules, one per line. Any non-duplication rules must be first in the rule set. ^2 will only generate sequences that begin with a 2. ^4.*2$ Filters out all sequences except those that begin with a 4 and end with a 2. If you are familiar with complex regular expression patterns, get fancy - mix them all into one pattern, use flags and so on. I find it easier and clearer to specify a rule on each line, but this is not as efficiently executed. Here's a reference on regular expressions: http://www.javascriptkit.com/javatutors/redev.shtml Conceived and implemented by Graeme Gerrard in Director/Javascript |