added solution to calculate a minimum distance between two words