Created
February 8, 2013 21:36
-
-
Save maxjacobson/4742133 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 is_palindrome? whatsit | |
str = whatsit.to_s.downcase.gsub(/ |[^\w\d]|\n/, '') | |
str == str.reverse ? true : false | |
end | |
to_check = [ | |
"a man, a plan, a canal: panama", | |
"Mr. Owl Ate My Metal Worm", | |
909, | |
100, | |
"sup jamal", | |
"racecar | |
racecar" | |
] | |
to_check.each do |checker| | |
if is_palindrome? checker | |
puts "a palindrome: #{checker}" | |
else | |
puts "not a palindrome: #{checker}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.codecrewny.org/post/42596443983/code-crew-code-challenge-1