Created
April 10, 2018 06:34
-
-
Save yfktn/64e53cd442173cd60266ed0b4106dff8 to your computer and use it in GitHub Desktop.
Palindrom atau tidak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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