From e8da699cbfeda073318ce6d95304dcc36ded68c4 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Wed, 14 Dec 2016 08:26:24 -0800 Subject: [PATCH] [2016][ruby][14.1] --- 2016/ruby/day_14.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/2016/ruby/day_14.rb b/2016/ruby/day_14.rb index ed28ea7..1054181 100644 --- a/2016/ruby/day_14.rb +++ b/2016/ruby/day_14.rb @@ -5,7 +5,13 @@ class Keys def initialize(seed) @seed = seed - @hash = Hash.new {|h,k| Digest::MD5.hexdigest("#{seed}#{k}") } + @hash = Hash.new {|h,k| + hash = Digest::MD5.hexdigest("#{seed}#{k}") + 2016.times do + hash = Digest::MD5.hexdigest(hash) + end + h[k] = hash + } end def each @@ -24,4 +30,4 @@ class Keys end keys = Keys.new('qzyelonm') -p keys.each.take(64) +p keys.each.take(64).last