Day 13.1
change
commit 9ddf2aad708638e321c726b7375352d5a4d66249
author Alpha Chen <alpha.chen@gmail.com>
date
parent 39326a22
diff --git a/day_13.rb b/day_13.rb
index 74297f0..30845e2 100644
--- a/day_13.rb
+++ b/day_13.rb
@@ -1,10 +1,11 @@
 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|
   units = units.to_i
   units *= (sign == "gain") ? 1 : -1
   happiness[left][right] = units
 end
+happiness["Alpha"] = Hash.new(0)
 
 puts happiness.keys.permutation.map { |arrangement|
   arrangement << arrangement.first