You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2016/ruby/day_20.rb

15 lines
274 B

blacklist = ARGF.read.split("\n").map {|line| Range.new(*line.split(?-).map(&:to_i)) }
ip = 0
count = 0
until ip > 4294967295
range = blacklist.find {|range| range.cover?(ip) }
if range.nil?
count += 1
ip += 1
else
ip = range.end + 1
end
end
puts count