You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2018/ruby/day_01.rb

9 lines
167 B

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