Skip to content

Instantly share code, notes, and snippets.

@psy-q
Created November 12, 2018 18:32
Show Gist options
  • Save psy-q/2f61b3216ed8a59311415ae4c011895f to your computer and use it in GitHub Desktop.
Save psy-q/2f61b3216ed8a59311415ae4c011895f to your computer and use it in GitHub Desktop.
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