From 43ab0a3a7a1e095f5f33f224ce73c413f49e156c Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Sun, 2 Dec 2018 12:41:05 +0000 Subject: Initial commit --- day01/part2 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 day01/part2 (limited to 'day01/part2') 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 -- cgit v1.2.3