aboutsummaryrefslogtreecommitdiff
path: root/day20/part1.rb
blob: 2a7bd2e5dbf9b314bf42bc5f706a974b74740a1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
file = $stdin.readlines.map(&:to_i)
size = file.length
pointer = 0

size.times do
  val = file[pointer]
  to = pointer + val

  file.delete_at(pointer)
  file.insert(to, val)

  pointer += 1 if to <= pointer
end