-
-
Save jsn/6d546b26a65d185a10d05e09a88ce581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check(l) | |
abba = false | |
l.scan(/([a-z])([a-z])\2\1/) do |rm| | |
next if $1 == $2 | |
return false if rm.pre_match =~ /\[[^\]]*$/ | |
abba = true | |
end | |
!!abba | |
end | |
puts STDIN.each_line.select { |l| check l }.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment