solved part 2
parent
d62dda2921
commit
8bd7ab3b2f
|
@ -2,4 +2,14 @@
|
|||
# Sum all numbers in the text file.
|
||||
|
||||
# Part 1
|
||||
sum = File.readlines('./input').map { |line| line.to_i)}.sum
|
||||
sum = File.readlines('./input').map { |line| line.to_i}.sum
|
||||
|
||||
# Part 2
|
||||
numbers = File.readlines('./input').map { |line| line.to_i}
|
||||
freqs = [0]
|
||||
|
||||
numbers.cycle do |num|
|
||||
freqs.push(freqs[-1] + num)
|
||||
break if freqs[0..-2].include?(freqs[-1])
|
||||
end
|
||||
puts freqs[-1]
|
||||
|
|
Loading…
Reference in New Issue