Solution for Day 02
This commit is contained in:
9
day_02/second.rb
Normal file
9
day_02/second.rb
Normal file
@ -0,0 +1,9 @@
|
||||
input = File.readlines('./input')
|
||||
|
||||
a = input.map do |pwl|
|
||||
matches = pwl.match /(?<start>\d+)-(?<end>\d+) (?<char>\w): (?<pw>\w+)/
|
||||
matches[:pw].chars.values_at(matches[:start].to_i-1, matches[:end].to_i-1).count(matches[:char])
|
||||
end
|
||||
puts a.inspect
|
||||
puts a.count(1)
|
||||
|
Reference in New Issue
Block a user