From 29524526c46eb1794e9824ab764e2f9822b94036 Mon Sep 17 00:00:00 2001 From: zainabdnaya Date: Thu, 28 Jul 2022 12:20:46 +0100 Subject: [PATCH] feat: subject of ReverseSecondHalf --- subjects/reversesecondhalf/README.md | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 subjects/reversesecondhalf/README.md diff --git a/subjects/reversesecondhalf/README.md b/subjects/reversesecondhalf/README.md new file mode 100644 index 00000000..074698cb --- /dev/null +++ b/subjects/reversesecondhalf/README.md @@ -0,0 +1,42 @@ +# ReverseSecondHalf + +### Instructions +Write a function `ReverseSecondHalf()` that takes a string as an argument and prints the second half reversed. If the length of the string is odd, round it up. + +- Prints the second half reversed followed by newline `\n`. +- if the string is empty, return `Invalid Output`. +- If the string's length equals one, return it, followed by newline `\n`. + +### Expected function + +```go +func ReverseSecondHalf(str string) string { +} +``` + +### Usage + +Here is a possible program to test your function: + +```go +package main + +import ( + "fmt" +) + +func main() { + ReverseSecondHalf("This is the 1st half This is the 2nd half") + ReverseSecondHalf("") + ReverseSecondHalf("Hello World") +} +``` + +And its output : + +```go +$ go run . | cat -e +flah dn2 eht si sihT$ +Invalid Output$ +dlroW$ +``` \ No newline at end of file