aboutsummaryrefslogtreecommitdiff
path: root/day17/part1
diff options
context:
space:
mode:
Diffstat (limited to 'day17/part1')
-rwxr-xr-xday17/part113
1 files changed, 13 insertions, 0 deletions
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]