From d21e58f81d28b4e411f1188b1fa065b99e24378b Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Tue, 5 Dec 2017 09:35:09 +0000 Subject: Day05 --- day05/part2 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 day05/part2 (limited to 'day05/part2') diff --git a/day05/part2 b/day05/part2 new file mode 100755 index 0000000..333d5d4 --- /dev/null +++ b/day05/part2 @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +input = $stdin.readlines.map(&:chomp).map(&:to_i) +pc = 0 +steps = 0 + +while pc >= 0 && pc < input.length do + newpc = pc + input[pc] + input[pc] += input[pc] >= 3 ? -1 : 1 + pc = newpc + steps += 1 +end + +puts steps -- cgit v1.2.3