Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # -*- ruby -*-
- def palindrome?(sentence='')
- return false if !sentence.is_a? String
- palindrome = sentence.delete(' ').downcase
- return !palindrome.empty? && palindrome == palindrome.reverse
- end
- sentence = gets.chomp
- if (palindrome?(sentence))
- puts "#{sentence} is a palindrome"
- else
- puts "#{sentence} is not a palindrome"
- end
- palindrome?
Advertisement
Add Comment
Please, Sign In to add comment