diff options
author | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-12-18 22:33:34 +0000 |
---|---|---|
committer | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-12-18 22:33:34 +0000 |
commit | b880d35aba91fd5c9a8a696705914d44da77e508 (patch) | |
tree | 28e7a3f037195053f3719ece0911ba5e8e64e84e /day17 | |
parent | a2019b1372bbd485ff36b49456af0189644711ff (diff) |
Day17 Part1
Diffstat (limited to 'day17')
-rw-r--r-- | day17/input | 1 | ||||
-rwxr-xr-x | day17/part1 | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/day17/input b/day17/input new file mode 100644 index 0000000..8661997 --- /dev/null +++ b/day17/input @@ -0,0 +1 @@ +328 diff --git a/day17/part1 b/day17/part1 new file mode 100755 index 0000000..e1c5027 --- /dev/null +++ b/day17/part1 @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +input = gets.chomp.to_i + +buf = [0] +pos = 0 + +2017.times do |num| + pos = ((pos + input) % buf.length) + 1 + buf.insert(pos, num + 1) +end + +p buf[pos + 1] |