From 2689553af0f68ee32ef56524fcf65ef46c0309f9 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Thu, 15 Dec 2016 08:18:32 -0800 Subject: [PATCH] [2016][ruby][15.1] --- 2016/ruby/day_15.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/2016/ruby/day_15.rb b/2016/ruby/day_15.rb index 36b9ae0..d7288d1 100644 --- a/2016/ruby/day_15.rb +++ b/2016/ruby/day_15.rb @@ -8,6 +8,7 @@ discs = DATA.each_line.map {|line| /Disc #\d has (?\d+) positions; at time=0, it is at position (?\d+)./ =~ line Disc.new(positions.to_i, position.to_i) } +discs << Disc.new(11, 0) p (0..Float::INFINITY).find {|t| discs.each.with_index.all? {|disc, index| @@ -16,5 +17,9 @@ p (0..Float::INFINITY).find {|t| } __END__ -Disc #1 has 5 positions; at time=0, it is at position 4. -Disc #2 has 2 positions; at time=0, it is at position 1. +Disc #1 has 17 positions; at time=0, it is at position 15. +Disc #2 has 3 positions; at time=0, it is at position 2. +Disc #3 has 19 positions; at time=0, it is at position 4. +Disc #4 has 13 positions; at time=0, it is at position 2. +Disc #5 has 7 positions; at time=0, it is at position 2. +Disc #6 has 5 positions; at time=0, it is at position 0.