mirror of https://github.com/01-edu/public.git
8ffc65ce3d | ||
---|---|---|
.. | ||
README.md | ||
main.go |
README.md
setspace
Instructions
Write a function that takes a PascalCase string
and returns the same string
with a space between each word.
-
The function must return an empty
string
if the input is an emptystring
. -
The function must return
"Error"
if the inputstring
is not a PascalCasestring
. -
The PascalCase begins with a capital letter, and each word begins with a capital letter without a space between them, for example: "HelloWorld" is a valid PascalCase
string
. -
The PascalCase cannot contain any non-alphabetic character, for example: "Hello World12" is not a valid PascalCase
string
.
Expected function
func SetSpace(s string) string {
}
Usage
Here is a possible program to test your function:
package main
import (
"fmt"
)
func main() {
fmt.Println(SetSpace("HelloWorld"))
fmt.Println(SetSpace("HelloWorld12"))
fmt.Println(SetSpace("Hello World"))
fmt.Println(SetSpace(""))
fmt.Println(SetSpace("LoremIpsumWord"))
}
And its output:
$ go run . | cat -e
Hello World$
Error$
Error$
$
Lorem Ipsum Word$
$