edit_distance: calculate edit distance between strings