diff options
Diffstat (limited to '09/b.rb')
-rw-r--r-- | 09/b.rb | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -0,0 +1,19 @@ +sum = 400480901 +lines = File.readlines('input.txt').map {|l| l.to_i} + +current_list = [] +current_sum = 0 + +lines.each do |n| + current_sum += n + current_list.push n + + while current_sum > sum && current_list.size > 1 + current_sum -= current_list.first + current_list.shift + end + + if current_sum == sum && current_list.size > 1 + puts current_list.min + current_list.max + end +end |