input = File.readlines('./input') a = input.map do |pwl| matches = pwl.match /(?\d+)-(?\d+) (?\w): (?\w+)/ matches[:pw].count(matches[:char]).between? matches[:start].to_i, matches[:end].to_i end puts a.count(true)