ctci hard, distance of words in a file