def choose_candidate_pair(candidates):
        """
        Choose a pair of address candidates ensuring they have the same length and starting with the highest scored ones

        :type candidates: dict[str, int]
        :param candidates: Count how often the longest common substrings appeared in the messages
        :return:
        """
        highscored = sorted(candidates, key=candidates.get, reverse=True)
        for i, h_i in enumerate(highscored):
            for h_j in highscored[i+1:]:
                if len(h_i) == len(h_j):
                    yield (h_i, h_j)
def choose_candidate_pair ( candidates ) : highscored = sorted ( candidates , key = candidates . get , reverse = True ) for i , h_i in enumerate ( highscored ) : for h_j in highscored [ i + 1 : ] : if len ( h_i ) == len ( h_j ) : yield ( h_i , h_j )
Choose a pair of address candidates ensuring they have the same length and starting with the highest scored ones

        :type candidates: dict[str, int]
        :param candidates: Count how often the longest common substrings appeared in the messages
        :return: