aboutsummaryrefslogtreecommitdiff
path: root/day17/part2
blob: 09fdd885eb46b4a6ff45977ccef9c1380499bb74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env ruby

input = gets.chomp.to_i

buf = [0]
pos = 0

50_000_000.times do |num|
  p num if num % 100000 == 0
  pos = ((pos + input) % buf.length) + 1
  buf.insert(pos, num + 1)
end

puts buf[buf.index(0) + 1]