diff options
-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] |