diff options
author | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-12-05 09:35:09 +0000 |
---|---|---|
committer | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-12-05 09:35:09 +0000 |
commit | d21e58f81d28b4e411f1188b1fa065b99e24378b (patch) | |
tree | c7d40a354dc6b240f618a0cad1950bfe42a88565 /day05/part1 | |
parent | a13c8efb2d501ecd32ba882657f1dd207dae85d8 (diff) |
Day05
Diffstat (limited to 'day05/part1')
-rwxr-xr-x | day05/part1 | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/day05/part1 b/day05/part1 new file mode 100755 index 0000000..0d0b4ec --- /dev/null +++ b/day05/part1 @@ -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] += 1 + pc = newpc + steps += 1 +end + +puts steps |