refactor: Tweak word selection PR
This commit is contained in:
13
src/util.go
13
src/util.go
@ -83,20 +83,19 @@ func init() {
|
|||||||
func randomText(n int, words []string) string {
|
func randomText(n int, words []string) string {
|
||||||
r := ""
|
r := ""
|
||||||
|
|
||||||
r += words[rand.Int()%len(words)]
|
|
||||||
r += " "
|
|
||||||
var last string
|
var last string
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
new := words[rand.Int()%len(words)]
|
w := words[rand.Int()%len(words)]
|
||||||
for last == new {
|
for last == w {
|
||||||
new = words[rand.Int()%len(words)]
|
w = words[rand.Int()%len(words)]
|
||||||
}
|
}
|
||||||
|
|
||||||
r += new
|
r += w
|
||||||
last = new
|
|
||||||
if i != n-1 {
|
if i != n-1 {
|
||||||
r += " "
|
r += " "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last = w
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Replace(r, "\n", " \n", -1)
|
return strings.Replace(r, "\n", " \n", -1)
|
||||||
|
Reference in New Issue
Block a user