forked from root/public
Compare commits
10 Commits
master
...
DEV-3180-n
Author | SHA1 | Date |
---|---|---|
Tiago Collot | 4475deeec6 | 2 years ago |
Tiago Collot | 5d89dee88b | 2 years ago |
Tiago Collot | a4742a8b75 | 2 years ago |
Tiago Collot | 9e37b35034 | 2 years ago |
Tiago Collot | 8c62b26f5f | 2 years ago |
Tiago Collot | 806189a644 | 2 years ago |
zainab Dnaya | 3ceea3f1af | 2 years ago |
zainab Dnaya | e3f1c38261 | 2 years ago |
zainabdnaya | 3309e89c4c | 2 years ago |
zainabdnaya | 8af2146941 | 2 years ago |
1 changed files with 45 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||||||
|
## fifthandskip |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a function `FifthAndSkip()` that takes a `string` and returns another `string`. The function separates every five characters of the `string` with a space and removes the sixth one. |
||||||
|
|
||||||
|
- If there are spaces in the middle of a word, ignore them and get the first character after the spaces until you reach a length of 5. |
||||||
|
- If the `string` is less than 5 characters returns `Invalid Output` followed by a newline `\n`. |
||||||
|
- If the `string` is empty return a newline `\n`. |
||||||
|
|
||||||
|
### Expected function |
||||||
|
|
||||||
|
```go |
||||||
|
func FifthAndSkip(str string) string { |
||||||
|
|
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function: |
||||||
|
|
||||||
|
```go |
||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"piscine" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
fmt.Print(piscine.FifthAndSkip("abcdefghijklmnopqrstuwxyz")) |
||||||
|
fmt.Print(piscine.FifthAndSkip("This is a short sentence")) |
||||||
|
fmt.Print(piscine.FifthAndSkip("1234")) |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
And its output: |
||||||
|
|
||||||
|
```console |
||||||
|
$ go run . | cat -e |
||||||
|
abcde ghijk mnopq stuwx z$ |
||||||
|
Thisi ashor sente ce$ |
||||||
|
Invalid Output$ |
||||||
|
``` |
Loading…
Reference in new issue