Solved Day 5
parent
667edb6369
commit
438a42fffd
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/env ruby
|
||||||
|
|
||||||
|
strings = File.readlines('./input').map(&:strip)
|
||||||
|
|
||||||
|
bad_pairs = Regexp.new(/ab|cd|pq|xy/).freeze
|
||||||
|
double_letters = Regexp.new(/([a-z])\1/).freeze
|
||||||
|
three_vowels = Regexp.new(/[aeiou]/).freeze
|
||||||
|
|
||||||
|
letter_pairs = Regexp.new(/([a-z]{2}).*\1/).freeze
|
||||||
|
alternate = Regexp.new(/([a-z]).\1/).freeze
|
||||||
|
|
||||||
|
part1 = strings.reject do |string|
|
||||||
|
bad_pairs.match?(string) == true or double_letters.match?(string) == false or string.scan(three_vowels).count < 3
|
||||||
|
end
|
||||||
|
|
||||||
|
puts part1.count
|
||||||
|
|
||||||
|
part2 = strings.reject do |string|
|
||||||
|
letter_pairs.match?(string) == false or alternate.match?(string) == false
|
||||||
|
end
|
||||||
|
|
||||||
|
puts part2.count
|
Loading…
Reference in New Issue