lib/dam_lev.rb in dam_lev-1.0.0 vs lib/dam_lev.rb in dam_lev-1.0.1

- old
+ new

@@ -7,16 +7,20 @@ (1..str1.length).each do |i| (1..str2.length).each do |j| sub_cost = str1[i-1] == str2[j-1] ? 0 : 1 - distance_matrix[i][j] = [distance_matrix[i-1][j] + 1, # deletion - distance_matrix[i][j-1] + 1, # insertion - distance_matrix[i-1][j-1] + sub_cost].min # substitution + distance_matrix[i][j] = [ + distance_matrix[i-1][j] + 1, # deletion + distance_matrix[i][j-1] + 1, # insertion + distance_matrix[i-1][j-1] + sub_cost # substitution + ].min if i > 1 && j > 1 && str1[i-1] == str2[j-2] && str1[i-2] == str2[j-1] - distance_matrix[i+1][j+1] = [distance_matrix[i][j], - distance_matrix[i-2][j-2] + sub_cost].min # transposition + distance_matrix[i][j] = [ + distance_matrix[i][j], + distance_matrix[i-2][j-2] + sub_cost # transposition + ].min end end end distance_matrix.last.last \ No newline at end of file