|
@@ -1,7 +1,6 @@
|
|
package main
|
|
package main
|
|
|
|
|
|
import (
|
|
import (
|
|
- "fmt"
|
|
|
|
"math/rand"
|
|
"math/rand"
|
|
"sort"
|
|
"sort"
|
|
"unicode"
|
|
"unicode"
|
|
@@ -20,7 +19,8 @@ func encodeWord(word []rune, wordLength int) {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-func encodeText(text []rune) (string, []string) {
|
|
+
|
|
|
|
+func EncodeText(text []rune) (string, []string) {
|
|
var currentWord []rune
|
|
var currentWord []rune
|
|
var newString []rune
|
|
var newString []rune
|
|
var encodedWords []string
|
|
var encodedWords []string
|
|
@@ -96,7 +96,8 @@ func decodeWord(word []rune, wordLength int, encodedWords []string) (string, []s
|
|
return string(word), encodedWords
|
|
return string(word), encodedWords
|
|
}
|
|
}
|
|
|
|
|
|
-func decodeText(text []rune, encodedWords []string) string {
|
|
+
|
|
|
|
+func DecodeText(text []rune, encodedWords []string) string {
|
|
var currentWord []rune
|
|
var currentWord []rune
|
|
var newString []rune
|
|
var newString []rune
|
|
|
|
|
|
@@ -123,12 +124,3 @@ func decodeText(text []rune, encodedWords []string) string {
|
|
|
|
|
|
return string(newString)
|
|
return string(newString)
|
|
}
|
|
}
|
|
-
|
|
|
|
-func main() {
|
|
|
|
- test := `This is a long looong test sentence,
|
|
|
|
-with some big (biiiiig) words!`
|
|
|
|
-
|
|
|
|
- encodedText, encodedWords := encodeText([]rune(test))
|
|
|
|
- fmt.Println(encodedText, encodedWords)
|
|
|
|
- fmt.Println(decodeText([]rune(encodedText), encodedWords))
|
|
|
|
-}
|
|
|