Skip to content

Instantly share code, notes, and snippets.

@rebeccajae
Created August 3, 2020 21:51
Show Gist options
  • Save rebeccajae/e4f4d4451af660e6fba8c59366cf4f64 to your computer and use it in GitHub Desktop.
Save rebeccajae/e4f4d4451af660e6fba8c59366cf4f64 to your computer and use it in GitHub Desktop.
what the fuck
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