From 82f8023623686e722ec6d3c98ee56515767bd63c Mon Sep 17 00:00:00 2001 From: "go-interview-practice-bot[bot]" <230190823+go-interview-practice-bot[bot]@users.noreply.github.com> Date: Sun, 12 Oct 2025 07:31:23 +0000 Subject: [PATCH] Add solution for Challenge 2 --- .../macborowy/solution-template.go | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 challenge-2/submissions/macborowy/solution-template.go diff --git a/challenge-2/submissions/macborowy/solution-template.go b/challenge-2/submissions/macborowy/solution-template.go new file mode 100644 index 00000000..0f0d8ac4 --- /dev/null +++ b/challenge-2/submissions/macborowy/solution-template.go @@ -0,0 +1,33 @@ +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 { + l := len(s) + a := make([]byte, l, l) + + for i := len(s) - 1; i >= 0; i-- { + a[l-1-i] = s[i] + } + + return string(a) +} \ No newline at end of file