aboutsummaryrefslogtreecommitdiff
path: root/day04/part1.rb
blob: 529572c8415c048427367e62427bd2bc5a7c4912 (plain)
1
2
3
4
5
6
7
8
9
pairs = $stdin.readlines.map { |line|
  line.strip.split(?,).map { |range|
    Range.new(*range.split(?-).map(&:to_i))
  }
}

puts pairs.select { |a, b|
  a.cover?(b) || b.cover?(a)
}.count