Resolve day 5
parent
93fba22c67
commit
3a34a3b4c4
|
@ -0,0 +1,22 @@
|
|||
#!/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)
|
Loading…
Reference in New Issue