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