2015/05/script.rb

23 lines
436 B
Ruby
Raw Normal View History

2021-11-23 13:04:49 +01:00
#!/usr/bin/env ruby
require_relative '../common'
def part1(input)
input.select do |string|
string.count('aeiou') >= 3 && string.match?(/(.)\1/) && !string.match?(/ab|cd|pq|xy/)
end.size
end
def part2(input)
input.select do |string|
string.match?(/(..).*\1/) && string.match?(/(.).\1/)
end.size
end
input = Input.new(__dir__).readlines
puts "=== Part 1 ==="
puts part1(input)
puts "=== Part 2 ==="
puts part2(input)