From 9a53ecf0501d393f012fe5320c64d659dc7558ae Mon Sep 17 00:00:00 2001 From: Zainab Dnaya Date: Mon, 19 Jun 2023 18:57:42 +0300 Subject: [PATCH] DEV-3180-new-go-exercise-fifthandskip (#1356) * fifthandskip * fifthandskip * Update README.md * Update README.md * style(fifthandskip): white-space, formatting * docs(fifthandskip): rename folder name - fix title header - add missing package 'piscine' - format indentation * rename * rename * docs(fifthandskip): add missing curly brace * docs(fifthandskip): instructions upgrade * docs(fifthandskip): fix output instead of input --------- Co-authored-by: Tiago Collot Co-authored-by: Michele Sessa --- subjects/fifthandskip/README.md | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 subjects/fifthandskip/README.md diff --git a/subjects/fifthandskip/README.md b/subjects/fifthandskip/README.md new file mode 100644 index 000000000..6aa52e774 --- /dev/null +++ b/subjects/fifthandskip/README.md @@ -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 return `Invalid Input` 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 Input$ +```