Codeeval question for finding patterns in a given string solved