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_22.rb

11 lines
269 B

Node = Struct.new(*%i[x y size used avail use])
nodes = ARGF
.read
.scan(%r|/dev/grid/node-x(\d+)-y(\d+)\s+(\d+)T\s+(\d+)T\s+(\d+)T\s*(\d+)%|)
.map {|match| Node.new(*match.map(&:to_i)) }
p nodes.permutation(2).count {|a,b|
a.used != 0 && a.used <= b.avail
}