wip
Alpha Chen 9 years ago
parent 39326a228c
commit 9ddf2aad70

@ -1,10 +1,11 @@
regex = /(\w+) would (\w+) (\d+) happiness units by sitting next to (\w+)/ regex = /(\w+) would (\w+) (\d+) happiness units by sitting next to (\w+)/
happiness = Hash.new {|h,k| h[k] = {} } happiness = Hash.new {|h,k| h[k] = Hash.new(0) }
DATA.read.scan(regex).each do |left, sign, units, right| DATA.read.scan(regex).each do |left, sign, units, right|
units = units.to_i units = units.to_i
units *= (sign == "gain") ? 1 : -1 units *= (sign == "gain") ? 1 : -1
happiness[left][right] = units happiness[left][right] = units
end end
happiness["Alpha"] = Hash.new(0)
puts happiness.keys.permutation.map { |arrangement| puts happiness.keys.permutation.map { |arrangement|
arrangement << arrangement.first arrangement << arrangement.first

Loading…
Cancel
Save