Created
July 31, 2023 17:28
-
-
Save nielvid/8aa35aef0e44685b4fc70e48284c295b to your computer and use it in GitHub Desktop.
check-palindrone-in-go
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" | |
"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