Skip to content

Instantly share code, notes, and snippets.

@nielvid
Created July 31, 2023 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nielvid/8aa35aef0e44685b4fc70e48284c295b to your computer and use it in GitHub Desktop.
Save nielvid/8aa35aef0e44685b4fc70e48284c295b to your computer and use it in GitHub Desktop.
check-palindrone-in-go
package main
import (
"fmt"
"strings"
)
func ReverseString(s string)string{
var b []string
a := strings.Split(s, "")
for k := range s{
b = append(b, a[len(s) -1 - k] )
}
return strings.Join(b,"")
}
func checkIfPalidrone(s string)bool{
//malam
reversed := ReverseString(s)
a := strings.Compare(s, reversed)
fmt.Println(a)
if a == 0{
return true
}else{
return false
}
}
func main(){
isPalindrone := checkIfPalidrone("tit")
fmt.Println(isPalindrone)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment