Created
August 3, 2020 21:51
-
-
Save rebeccajae/e4f4d4451af660e6fba8c59366cf4f64 to your computer and use it in GitHub Desktop.
what the fuck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
"regexp" | |
) | |
func main() { | |
bytes, err := ioutil.ReadAll(os.Stdin) | |
if err != nil { | |
panic(err) | |
} | |
a := regexp.MustCompile(`\s+`) | |
words := a.Split(string(bytes), -1) | |
for _, word := range words { | |
if len(word) <= 0 { | |
continue | |
} | |
fmt.Printf("%s ", kubeify(word)) | |
} | |
fmt.Println() | |
} | |
func kubeify(word string) string { | |
runeified := []rune(word) | |
length := len(runeified) | |
if length < 3 { | |
return word | |
} | |
return fmt.Sprintf("%s%d%s", string(runeified[0]), length-2, string(runeified[len(runeified)-1])) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment