Day 20.0
change
commit ce1fc224af9bb431e1df7ef7c3435c3a5d42600e
author Alpha Chen <alpha.chen@gmail.com>
date
parent c544ffed
diff --git a/ruby/day_20.rb b/ruby/day_20.rb
new file mode 100644
index 0000000..4e037df
--- /dev/null
+++ b/ruby/day_20.rb
@@ -0,0 +1,14 @@
+require "prime"
+
+house = 1
+while true
+  house += 1
+
+  factors = house.prime_division
+  presents = factors.map {|f,x| (x+1).times.map {|i| f**i }.inject(:+) }.inject(:*)
+
+  if presents >= 3600000
+    puts house
+    exit
+  end
+end