diff options
author | Nat Lasseter <user@4574.co.uk> | 2018-12-02 12:41:05 +0000 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2018-12-02 12:41:05 +0000 |
commit | 43ab0a3a7a1e095f5f33f224ce73c413f49e156c (patch) | |
tree | 1d4bfdb3385562511231f4389e29ca2279a916b1 /day01/part2 |
Initial commit
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 |