Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
aocday1
ints = File.readlines("input.txt").map(&:to_i)
puts ints.sum
require "set"
ints = File.readlines("input.txt").map(&:to_i)
sum = 0
observations = [sum].to_set
while true
ints.each do |i|
sum += i
if observations.include?(sum)
puts "sum=#{sum}"
exit
end
observations << sum
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment