Instantly share code, notes, and snippets.

What would you like to do?
Перевірка строки на паліндром.rb
str = " ABCооооолльоCBA"
p str.gsub(/[^A-Z]/,"") == str.gsub(/[^A-Z]/,"").reverse
p str.scan(/[A-Z]/).join("") == str.scan(/[A-Z]/).join("").reverse
p str.split("").select{|x| x>="A" && x<="Z"}.join("") == str.split("").select{|x| x>="A" && x<="Z"}.join("").reverse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment