aboutsummaryrefslogtreecommitdiff
path: root/day17/part1
blob: e1c5027e86bff761fec90a820121c920d91cc836 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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]