diff options
Diffstat (limited to 'day05/part2')
-rwxr-xr-x | day05/part2 | 14 |
1 files changed, 14 insertions, 0 deletions
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 |