forked from root/public
Compare commits
8 Commits
master
...
DEV-3178-n
Author | SHA1 | Date |
---|---|---|
Tiago Collot | 80a9d11c67 | 2 years ago |
Tiago Collot | 817865cf63 | 2 years ago |
Tiago Collot | 17471aff56 | 2 years ago |
Tiago Collot | bc1eb98c07 | 2 years ago |
zainab Dnaya | cdb056877f | 2 years ago |
zainab Dnaya | bf464b6e0e | 2 years ago |
zainab Dnaya | 8aa8b9d658 | 2 years ago |
zainabdnaya | defa5e6b5d | 2 years ago |
1 changed files with 47 additions and 0 deletions
@ -0,0 +1,47 @@
|
||||
## wordflip |
||||
|
||||
### Instructions |
||||
|
||||
Write a function `WordFlip()` that receives a `string` and returns it in reverse order. |
||||
|
||||
- Prints the Output followed by newline `\n`. |
||||
- If the string is empty, return `Invalid Output`. |
||||
- Ignore spaces if there are more than one space in between words and ignore all spaces at the edge of the `string`. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func WordFlip(str string) string { |
||||
|
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
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: |
||||
|
||||
```console |
||||
$ go run . | cat -e |
||||
last second First$ |
||||
Invalid Output$ |
||||
$ |
||||
you! of all hello$ |
||||
``` |
Loading…
Reference in new issue