From ca701f2f9b5af6ef459fc035e0eb68b5328a387a Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sat, 1 Dec 2018 20:30:30 -0800 Subject: [PATCH] [2018][ruby][1.x] --- 2018/ruby/day_01.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 2018/ruby/day_01.rb diff --git a/2018/ruby/day_01.rb b/2018/ruby/day_01.rb new file mode 100644 index 0000000..0594765 --- /dev/null +++ b/2018/ruby/day_01.rb @@ -0,0 +1,8 @@ +require "set" + +seen = Set.new +ARGF.read.lines.map(&:to_i).cycle.each.with_object([0]) do |i,n| + n[0] += i + p n[0] and exit if seen.include?(n[0]) + seen << n[0] +end