If you know regular expressions, you might find this to be geek fun. A friend of mine posted this, without a solution, but once I started working it, it seemed put together well enough it was likely solvable. Eventually I did solve it, but not before coding up a web interface for making it easier to interact with, which I recommend using if you are going to try this out. Or just print it out. Clic