All problems
Weighted Edit Distance Costs
Problem
Compute edit distance with configurable substitution cost: insertion and deletion cost 1, substitution costs sub_cost when characters differ.
Given the two strings and sub_cost, return the distance.
Hint
Substitution competes with delete plus insert.
Test cases
case 1
in: ["cat","cot",1]
expected: 1
case 2
in: ["cat","cot",2]
expected: 2
case 3
in: ["ab","ba",1]
expected: 2
Starter codePython
def weighted_edit_distance_costs(a, b, sub_cost):
# Your code here
pass3 test cases · run your code against them in the editor