Skip to content

Commit d9174a8

Browse files
committed
improvements on comments
1 parent b4080a9 commit d9174a8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

strings/levenshteinDistance.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This algorithm calculates the distance between two strings.
3-
Parameters: two strings to compare
3+
Parameters: two strings to compare and weights of insertion, substitution and deletion.
44
Output: distance between both strings
55
*/
66

@@ -59,8 +59,15 @@ func main() {
5959
str1 := "stingy"
6060
str2 := "ring"
6161

62-
strDistance := levenshteinDistance(str1, str2, 1, 1, 1)
63-
fmt.Printf("Distance between %s and %s is: %d.", str1, str2, strDistance)
62+
// Using weight 1 for insertion, substitution and deletion
63+
strDistance1 := levenshteinDistance(str1, str2, 1, 1, 1)
64+
fmt.Printf("Distance between \"%s\" and \"%s\" is: %d.\n", str1, str2, strDistance1)
65+
// Output: Distance between "stingy" and "ring" is: 3.
66+
67+
// Using weight 1 for insertion/substitution and weight 3 for deletion
68+
strDistance2 := levenshteinDistance(str1, str2, 1, 1, 3)
69+
fmt.Printf("Distance between \"%s\" and \"%s\" is: %d.\n", str1, str2, strDistance2)
70+
// Output: Distance between "stingy" and "ring" is: 7.
6471

6572
return
6673
}

0 commit comments

Comments
 (0)