Avoid duplicates

This commit is contained in:
Yohann D'ANELLO 2022-05-04 21:46:42 +02:00
parent b591a6d799
commit c4de4bceee
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 4 additions and 0 deletions

View File

@ -196,6 +196,10 @@ func InsertWord(arr []word, w word) []word {
return append(arr, w)
}
w2 := arr[len(arr)-1]
if w.content == w2.content {
// The word is already present
return arr
}
if w.distance < w2.distance {
return append(arr, w)
}