|
|
@ -1,12 +1,12 @@ |
|
|
|
# wordflip |
|
|
|
## wordflip |
|
|
|
|
|
|
|
|
|
|
|
### Instructions |
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
|
|
Write a function `WordFlip()` that receives a string and returns it with the first and last words flipped. |
|
|
|
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`. |
|
|
|
- Prints the Output followed by newline `\n`. |
|
|
|
- If the string is empty, return `Invalid Output`. |
|
|
|
- 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. |
|
|
|
- Ignore spaces if it's more then one space in between words and all spaces in the edge of the words or sentences. |
|
|
|
|
|
|
|
|
|
|
|
### Expected function |
|
|
|
### Expected function |
|
|
|
|
|
|
|
|
|
|
@ -23,19 +23,22 @@ Here is a possible program to test your function: |
|
|
|
```go |
|
|
|
```go |
|
|
|
package main |
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import "fmt" |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
"piscine" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
fmt.Print(WordFlip("First second last")) |
|
|
|
fmt.Print(piscine.WordFlip("First second last")) |
|
|
|
fmt.Print(WordFlip("")) |
|
|
|
fmt.Print(piscine.WordFlip("")) |
|
|
|
fmt.Print(WordFlip(" ")) |
|
|
|
fmt.Print(piscine.WordFlip(" ")) |
|
|
|
fmt.Print(WordFlip(" hello all of you! ")) |
|
|
|
fmt.Print(piscine.WordFlip(" hello all of you! ")) |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
And its output: |
|
|
|
And its output: |
|
|
|
|
|
|
|
|
|
|
|
```go |
|
|
|
```console |
|
|
|
$ go run . | cat -e |
|
|
|
$ go run . | cat -e |
|
|
|
last second First$ |
|
|
|
last second First$ |
|
|
|
Invalid Output$ |
|
|
|
Invalid Output$ |
|
|
|