From ebfa86a1de7dc3325c9f3235b5169935e38290d6 Mon Sep 17 00:00:00 2001 From: "go-interview-practice-bot[bot]" <230190823+go-interview-practice-bot[bot]@users.noreply.github.com> Date: Sat, 18 Oct 2025 07:45:46 +0000 Subject: [PATCH] Add solution for Challenge 2 --- .../ADEMOLA200/solution-template.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 challenge-2/submissions/ADEMOLA200/solution-template.go diff --git a/challenge-2/submissions/ADEMOLA200/solution-template.go b/challenge-2/submissions/ADEMOLA200/solution-template.go new file mode 100644 index 00000000..b0a838de --- /dev/null +++ b/challenge-2/submissions/ADEMOLA200/solution-template.go @@ -0,0 +1,36 @@ +package main + +import ( + "bufio" + "fmt" + "os" +) + +func main() { + // Read input from standard input + scanner := bufio.NewScanner(os.Stdin) + if scanner.Scan() { + input := scanner.Text() + + // Call the ReverseString function + output := ReverseString(input) + + // Print the result + fmt.Println(output) + } +} + +// ReverseString returns the reversed string of s. +func ReverseString(s string) string { + // Convert string to a slice of runes to handle Unicode properly + runes := []rune(s) + n := len(runes) + + // Reverse the slice of runes + for i := 0; i < n/2; i++ { + runes[i], runes[n-1-i] = runes[n-1-i], runes[i] + } + + // Convert back to string + return string(runes) +}