From d65f656e115e975ca379f3425c895f1c65510b01 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, 4 Oct 2025 09:19:28 +0000 Subject: [PATCH] Add solution for Challenge 2 --- .../akolpakov-somehash/solution-template.go | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 challenge-2/submissions/akolpakov-somehash/solution-template.go diff --git a/challenge-2/submissions/akolpakov-somehash/solution-template.go b/challenge-2/submissions/akolpakov-somehash/solution-template.go new file mode 100644 index 00000000..a8d89756 --- /dev/null +++ b/challenge-2/submissions/akolpakov-somehash/solution-template.go @@ -0,0 +1,35 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strings" +) + +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 { + var b strings.Builder + r := []rune(s) + l := len(r) + b.Grow(l) + + for i:=l-1; i>=0;i-- { + b.WriteRune(r[i]) + } + return b.String() +}