Check if Palindrome

Check if a string is a palindrome by comparing characters from both ends.

Code

Algorithms
clean = s.downcase.gsub(/[^a-z0-9]/, '')
return clean == clean.reverse

Parameters

The string to check

Server

More Ruby Snippets