23 lines
436 B
Ruby
Executable File
23 lines
436 B
Ruby
Executable File
#!/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)
|