mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
688 B
42 lines
688 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"unicode"
|
||
|
|
||
5 years ago
|
student "student"
|
||
|
|
||
4 years ago
|
"github.com/01-edu/public/go/tests/lib"
|
||
5 years ago
|
)
|
||
|
|
||
|
func capitalize(s string) string {
|
||
|
r := []rune(strings.ToLower(s))
|
||
|
|
||
5 years ago
|
if unicode.Is(unicode.Latin, r[0]) {
|
||
5 years ago
|
r[0] = unicode.ToUpper(r[0])
|
||
|
}
|
||
|
|
||
|
for i := 1; i < len(r); i++ {
|
||
5 years ago
|
if !unicode.IsDigit(r[i-1]) && !unicode.Is(unicode.Latin, r[i-1]) {
|
||
5 years ago
|
r[i] = unicode.ToUpper(r[i])
|
||
|
}
|
||
|
}
|
||
|
return string(r)
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
table := append(
|
||
|
lib.MultRandASCII(),
|
||
|
"Hello! How are you? How+are+things+4you?",
|
||
|
"Hello! How are you?",
|
||
|
"a",
|
||
|
"z",
|
||
|
"!",
|
||
|
"9a",
|
||
|
"9a LALALA!",
|
||
|
)
|
||
|
for _, arg := range table {
|
||
|
lib.Challenge("Capitalize", student.Capitalize, capitalize, arg)
|
||
|
}
|
||
|
}
|