From defa5e6b5dff6172dd1469c36e2ac3cc57e6df93 Mon Sep 17 00:00:00 2001 From: zainabdnaya Date: Fri, 29 Jul 2022 02:54:48 +0100 Subject: [PATCH] feat: subject of wordfflip --- subjects/wordflip/README.md | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 subjects/wordflip/README.md diff --git a/subjects/wordflip/README.md b/subjects/wordflip/README.md new file mode 100644 index 00000000..49d4d62c --- /dev/null +++ b/subjects/wordflip/README.md @@ -0,0 +1,46 @@ +# WordFlip + +### Instructions + +Write a function `WordFlip()` that receives a string and returns it with the first and last words flipped. + +- Prints the Output followed by newline `\n`. +- If the string is empty, return `Invalid Output`. +- Ignore spaces if it's more then onr space in between words and all spaces in the edge of the words or sentences. + +### Expected function + +```go +func WordFlip(str string) string { +} +``` + +### Usage + +Here is a possible program to test your function: + +```go +package main + +import ( + "fmt" +) + +func main() { + fmt.Print(WordFlip("First second last")) + fmt.Print(WordFlip("")) + fmt.Print(WordFlip(" ")) //all spaces + fmt.Print(WordFlip(" hello all of you! ")) + +} +``` + +And its output : + +```go +$ go run . | cat -e +last second First$ +Invalid Output$ +$ +you! of all hello$ +``` \ No newline at end of file