From 93610858d046ee9436d81853ce1e724ff03d5d19 Mon Sep 17 00:00:00 2001 From: zikaeroh <48577114+zikaeroh@users.noreply.github.com> Date: Sat, 23 May 2020 16:47:28 -0700 Subject: [PATCH] Add words even if empty, to prevent undersized lists --- internal/words/words.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/words/words.go b/internal/words/words.go index 34c94a0..4f64396 100644 --- a/internal/words/words.go +++ b/internal/words/words.go @@ -22,26 +22,21 @@ func NewList(words []string) List { for _, w := range words { w = strings.TrimSpace(w) w = strings.ToUpper(w) - if w != "" { - cleaned = append(cleaned, w) - } + cleaned = append(cleaned, w) } return newList(cleaned) } func NewListFromLines(s string) List { + s = strings.TrimSpace(s) words := make([]string, 0, strings.Count(s, "\n")) - scanner := bufio.NewScanner(strings.NewReader(s)) for scanner.Scan() { word := scanner.Text() word = strings.TrimSpace(word) word = strings.ToUpper(word) - - if word != "" { - words = append(words, word) - } + words = append(words, word) } return newList(words)