refactor: Tweak word selection PR

This commit is contained in:
Aetnaeus 2023-04-11 16:06:43 -04:00
parent 5a179f25b4
commit 65af3c3480

@ -83,20 +83,19 @@ func init() {
func randomText(n int, words []string) string {
r := ""
r += words[rand.Int()%len(words)]
r += " "
var last string
for i := 0; i < n; i++ {
new := words[rand.Int()%len(words)]
for last == new {
new = words[rand.Int()%len(words)]
w := words[rand.Int()%len(words)]
for last == w {
w = words[rand.Int()%len(words)]
}
r += new
last = new
r += w
if i != n-1 {
r += " "
}
last = w
}
return strings.Replace(r, "\n", " \n", -1)