diff --git a/solutions/go/acronym/1/acronym.go b/solutions/go/acronym/1/acronym.go new file mode 100644 index 0000000..9c793ff --- /dev/null +++ b/solutions/go/acronym/1/acronym.go @@ -0,0 +1,22 @@ +// This is a "stub" file. It's a little start on your solution. +// It's not a complete solution though; you have to write some code. + +// Package acronym should have a package comment that summarizes what it's about. +// https://golang.org/doc/effective_go.html#commentary +package acronym + +import "strings" + +// Abbreviate should have a comment documenting it. +func Abbreviate(s string) string { + f := strings.FieldsFunc(s, func(r rune) bool { + return r == ' ' || r == '-' || r == '_' + }) + + var res strings.Builder + for _, w := range f { + res.WriteString(strings.ToUpper(w[:1])) + } + + return res.String() +}