diff --git a/challenge-2/submissions/4m4x/solution-template.go b/challenge-2/submissions/4m4x/solution-template.go new file mode 100644 index 000000000..1506be4e0 --- /dev/null +++ b/challenge-2/submissions/4m4x/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 { + runes := []rune(s) + output := []string{} + + for i := len(runes) - 1; i > -1; i-- { + output = append(output, string(s[i])) + } + + s = strings.Join(output, "") + return s +}