Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions challenge-2/submissions/akolpakov-somehash/solution-template.go
Original file line number Diff line number Diff line change
@@ -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()
}