Skip to content

Instantly share code, notes, and snippets.

@fenixbrassi
Created December 16, 2013 03:17
Show Gist options
  • Save fenixbrassi/7981814 to your computer and use it in GitHub Desktop.
Save fenixbrassi/7981814 to your computer and use it in GitHub Desktop.
Palindrome
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