public
Created

Перевірка строки на паліндром.rb

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.