aboutsummaryrefslogtreecommitdiff
path: root/day01/part2
diff options
context:
space:
mode:
authorNat Lasseter <user@4574.co.uk>2018-12-02 12:41:05 +0000
committerNat Lasseter <user@4574.co.uk>2018-12-02 12:41:05 +0000
commit43ab0a3a7a1e095f5f33f224ce73c413f49e156c (patch)
tree1d4bfdb3385562511231f4389e29ca2279a916b1 /day01/part2
Initial commit
Diffstat (limited to 'day01/part2')
-rwxr-xr-xday01/part217
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