Skip to content

Instantly share code, notes, and snippets.

@mikalai-yankouski
Last active November 27, 2018 12:59
Show Gist options
  • Save mikalai-yankouski/67f15c59f91f16de1f9a9c45c7a385d8 to your computer and use it in GitHub Desktop.
Save mikalai-yankouski/67f15c59f91f16de1f9a9c45c7a385d8 to your computer and use it in GitHub Desktop.
Дана строка. Необходимо проверить, является ли она палиндромом.
loop do
puts "Enter the word you want to check for palindrom words ('example' for example, 'exit' for quite)"
word = gets.chomp.downcase.strip
break if word == "exit"
if word == "example"
puts "Word '#{word}' is not a palindrome. Because '#{word}' not equal '#{word.reverse}'"
puts "Word 'deified' is a palindrome! Because word 'deified' equally read backwards\n"
elsif word == word.reverse
puts "You input: '#{word}'. It's a palindrome!"
else
puts "You input: '#{word}'. It's not a palindrome"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment