Skip to content

Instantly share code, notes, and snippets.

@yfktn
Created April 10, 2018 06:34
Show Gist options
  • Save yfktn/64e53cd442173cd60266ed0b4106dff8 to your computer and use it in GitHub Desktop.
Save yfktn/64e53cd442173cd60266ed0b4106dff8 to your computer and use it in GitHub Desktop.
Palindrom atau tidak
package main
import (
"fmt"
)
func main() {
test := "able was i ere i saw elba"
testBalik := reverseString(test)
if test == reverseString(test) {
fmt.Println("PALINDROM")
} else {
fmt.Println("Bukan Palindrom")
}
}
func reverseString(ini string) string {
var s []byte
for i:=len(ini)-1;i>=0;i-- {
s = append(s, ini[i])
}
return string(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment