Skip to content

Instantly share code, notes, and snippets.

@alexandersazonof
Last active December 2, 2018 13:23
Show Gist options
  • Save alexandersazonof/9bcf8105213bafa8893329f48c5e5a33 to your computer and use it in GitHub Desktop.
Save alexandersazonof/9bcf8105213bafa8893329f48c5e5a33 to your computer and use it in GitHub Desktop.
#Дана строка. Необходимо проверить, является ли она палиндромом.
str = "kazask"
if str == str.reverse
puts "#{str} является палиндромом"
else
puts "#{str} не является палиндромом"
end
@aya-soft
Copy link

aya-soft commented Dec 2, 2018

А как избежать проблемы букв разной высоты?

@alexandersazonof
Copy link
Author

alexandersazonof commented Dec 2, 2018

А как избежать проблемы букв разной высоты?

class String
  def is_palindrome?
    self.downcase == self.reverse.downcase
  end
end

@aya-soft
Copy link

aya-soft commented Dec 2, 2018

🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment