From c4de4bceee4e08364e04e3106a13b9e278b5e4e4 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 4 May 2022 21:46:42 +0200 Subject: [PATCH] Avoid duplicates --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 28e5211..46cc518 100644 --- a/main.go +++ b/main.go @@ -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) }