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.
lee
8ffc65ce3d
|
10 months ago | |
---|---|---|
.. | ||
README.md | 10 months ago | |
main.go | 10 months ago |
README.md
wordflip
Instructions
Write a function WordFlip()
that takes a string
as input and returns it in reverse order.
- The output should be followed by a newline
\n
. - If the string is empty, return
Invalid Output
. - Ignore multiple spaces between words and trim any leading or trailing spaces in the string.
Expected function
func WordFlip(str string) string {
}
Usage
Here is a possible program to test your function:
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.WordFlip("First second last"))
fmt.Print(piscine.WordFlip(""))
fmt.Print(piscine.WordFlip(" "))
fmt.Print(piscine.WordFlip(" hello all of you! "))
}
And its output:
$ go run . | cat -e
last second First$
Invalid Output$
$
you! of all hello$