Created
December 16, 2013 03:17
-
-
Save fenixbrassi/7981814 to your computer and use it in GitHub Desktop.
Palindrome
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_a_palindrome?(str) | |
str.to_s.chomp == str.to_s.chomp.reverse | |
end | |
puts " give me a word" | |
w = gets | |
puts (is_a_palindrome? w) ? "Is a Palindrome": "Is not | |
a Palindrome" | |
-------------------- | |
Result in console | |
C:\Training>ruby is_palindrome.rb | |
give me a word | |
oco | |
Is a Palindrome | |
C:\Training>ruby is_palindrome.rb | |
give me a word | |
orco | |
Is not a Palindrome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment