Pattern Text Matching - Coding problem | OneNoughtOne