blob: d02c1e2e3e55187aba193a3a29b9fe5c3757a465 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Range
def overlap?(other)
cover?(other.first) || other.cover?(first)
end
end
pairs = $stdin.readlines.map { |line|
line.strip.split(?,).map { |range|
Range.new(*range.split(?-).map(&:to_i))
}
}
puts pairs.select { |a, b|
a.overlap?(b)
}.count
|