How to solve complicated problems through an example of building a simple pattern scanner