diff --git a/epi_judge_cpp_solutions/levenshtein_distance.cc b/epi_judge_cpp_solutions/levenshtein_distance.cc index d30535c2e..09cef29db 100644 --- a/epi_judge_cpp_solutions/levenshtein_distance.cc +++ b/epi_judge_cpp_solutions/levenshtein_distance.cc @@ -42,9 +42,9 @@ int ComputeDistanceBetweenPrefixes( int substitute_last = ComputeDistanceBetweenPrefixes( A, A_idx - 1, B, B_idx - 1, distance_between_prefixes_ptr); int add_last = ComputeDistanceBetweenPrefixes( - A, A_idx - 1, B, B_idx, distance_between_prefixes_ptr); - int delete_last = ComputeDistanceBetweenPrefixes( A, A_idx, B, B_idx - 1, distance_between_prefixes_ptr); + int delete_last = ComputeDistanceBetweenPrefixes( + A, A_idx - 1, B, B_idx, distance_between_prefixes_ptr); distance_between_prefixes[A_idx][B_idx] = 1 + min({substitute_last, add_last, delete_last}); } diff --git a/epi_judge_python_solutions/levenshtein_distance.py b/epi_judge_python_solutions/levenshtein_distance.py index dbc76c1d7..16534314b 100644 --- a/epi_judge_python_solutions/levenshtein_distance.py +++ b/epi_judge_python_solutions/levenshtein_distance.py @@ -18,8 +18,8 @@ def compute_distance_between_prefixes(A_idx, B_idx): substitute_last = compute_distance_between_prefixes( A_idx - 1, B_idx - 1) - add_last = compute_distance_between_prefixes(A_idx - 1, B_idx) - delete_last = compute_distance_between_prefixes(A_idx, B_idx - 1) + add_last = compute_distance_between_prefixes(A_idx, B_idx - 1) + delete_last = compute_distance_between_prefixes(A_idx - 1, B_idx) return 1 + min(substitute_last, add_last, delete_last) return compute_distance_between_prefixes(len(A) - 1, len(B) - 1)