Created
November 12, 2018 18:32
-
-
Save psy-q/2f61b3216ed8a59311415ae4c011895f to your computer and use it in GitHub Desktop.
This file contains 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
def filter(string) | |
string.tr(',', '').tr(' ', '').tr('-', '') | |
end | |
def compare(string) | |
orig = filter(string).downcase | |
reversed = filter(string).reverse.downcase | |
orig == reversed | |
end | |
string = 'A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama' | |
puts compare(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment