#NEWLINE# def shortest( self , word1 , word2 ) : #NEWLINE# #INDENT# indexes1 = self . wordIndex [ word1 ] #NEWLINE# indexes2 = self . wordIndex [ word2 ] #NEWLINE# ( i , j , dist ) = ( 0 , 0 , float ( 'inf' ) ) #NEWLINE# while ( ( i < len ( indexes1 ) ) and ( j < len ( indexes2 ) ) ) : #NEWLINE# #INDENT# dist = min ( dist , abs ( ( indexes1 [ i ] - indexes2 [ j ] ) ) ) #NEWLINE# if ( indexes1 [ i ] < indexes2 [ j ] ) : #NEWLINE# #INDENT# i += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# j += 1 #NEWLINE# #UNINDENT# #UNINDENT# return j