Skip to content

Instantly share code, notes, and snippets.

@Noy
Created July 17, 2020 21:28
Show Gist options
  • Save Noy/df6cf35ef721fc2e8c0602efe2fa6329 to your computer and use it in GitHub Desktop.
Save Noy/df6cf35ef721fc2e8c0602efe2fa6329 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"strings"
)
func main() {
log.Println(checkCard("d2"))
}
func checkCard(card string) bool {
if len(card) != 2 {
return false
}
cardValues := []string{"2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"}
cardSuits := []string{"s", "c", "h", "d"}
for _, cV := range cardValues {
if strings.Contains(card, cV) {
for _, cS := range cardSuits {
if strings.Contains(card, cS) {
return true
}
}
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment