Skip to content

Instantly share code, notes, and snippets.

@fsouza
Last active December 20, 2015 10:31
Show Gist options
  • Save fsouza/6116437 to your computer and use it in GitHub Desktop.
Save fsouza/6116437 to your computer and use it in GitHub Desktop.
package str
func Reverse(input string) string {
return ""
}
package str
import (
"testing"
)
func TestReverse(t *testing.T) {
input := "AB"
output := Reverse(input)
expected := "BA"
if output != expected {
t.Errorf("Expected %s, got %s", expected, output)
}
}
@rodsenra
Copy link

package str
import "fmt"

func Reverse(input string) string {
rune_array := []rune(input)
size := len(rune_array)
var inverted []rune
inverted = make([]rune, size)
fmt.Println(size)
for i, v := range rune_array {
fmt.Printf("%d %s\n", i, v)
inverted[size-i-1] = v
}
return string(inverted)
}

@davidsonfellipe
Copy link

@tulios
Copy link

tulios commented Jul 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment