Browse Source

Shuffling text

Piotr Czajkowski 3 years ago
parent
commit
a4923af933
1 changed files with 20 additions and 0 deletions
  1. 20 0
      app.go

+ 20 - 0
app.go

@@ -0,0 +1,20 @@
+package main
+
+import (
+	"fmt"
+	"math/rand"
+)
+
+func main() {
+	test := "Poświadczam"
+	runes := []rune(test)
+	part := runes[1 : len(runes)-1]
+	partLength := len(part)
+	fmt.Println(string(part))
+
+	rand.Shuffle(partLength, func(i, j int) {
+		part[i], part[j] = part[j], part[i]
+	})
+
+	fmt.Println(string(part))
+}