Your question is Dynamic Programming for Strings. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
qXR may receive OCR text containing character substitutions, missing characters, or adjacent character swaps. Given a source string and a target string, compute the minimum cost to align the source with the target.
Allowed operations are:
Each operation has a caller-provided non-negative cost. The alignment proceeds from left to right, so a transposition consumes exactly two source and two target characters.
Implement minimum_alignment_cost(source, target, insert_cost, delete_cost, replace_cost, transpose_cost). Return an integer representing the minimum alignment cost. The inputs are strings and integer operation costs.
def minimum_alignment_cost(source, target, insert_cost, delete_cost, replace_cost, transpose_cost):