Skip to content

Instantly share code, notes, and snippets.

@davidkellis
Created December 7, 2018 18:15
Show Gist options
  • Save davidkellis/8880c09faa8625504e53f2aea98d79c4 to your computer and use it in GitHub Desktop.
Save davidkellis/8880c09faa8625504e53f2aea98d79c4 to your computer and use it in GitHub Desktop.
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