diff options
Diffstat (limited to 'day01/part2')
-rwxr-xr-x | day01/part2 | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/day01/part2 b/day01/part2 new file mode 100755 index 0000000..d48de47 --- /dev/null +++ b/day01/part2 @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +input = $stdin.readlines.map(&:to_i) + +lf = 0 +freq = [0] + +loop do + input.each do |i| + lf += i + if freq.include?(lf) + puts lf + exit + end + freq << lf + end +end |