Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created January 4, 2018 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 chriswebb09/90327141ea6b07a999c5caddbae088be to your computer and use it in GitHub Desktop.
Save chriswebb09/90327141ea6b07a999c5caddbae088be to your computer and use it in GitHub Desktop.
func palindrome(string: String) -> Bool {
var replacedString = string.replacingOccurrences(of: " ", with: "")
replacedString = replacedString.components(separatedBy:.punctuationCharacters).joined()
return replacedString.lowercased() == String(replacedString.lowercased().reversed())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment