def score_function(word1, word2):
    """A score_function that computes the edit distance between word1 and word2."""

    if not word1: # Fill in the condition
        # BEGIN Q6
        return len(word2)
        # END Q6

    elif not word2: # Feel free to remove or add additional cases
        # BEGIN Q6
        return len(word1)
        # END Q6

    elif word1[0] == word2[0]:
        return score_function(word1[1:], word2[1:])

    else:
        add_char = score_function(word1, word2[1:])  # Fill in these lines
        remove_char = score_function(word1[1:], word2)
        substitute_char = score_function(word1[1:], word2[1:])
        # BEGIN Q6
        return 1 + min(add_char, remove_char, substitute_char)
        # END Q6