about summary refs log tree commit diff
path: root/day15.rb
blob: f108b61ef3cdcbb7da3b3e89bf7410715791c465 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
t = 0
step = 1

(IO.readlines("day15") << "Disc #7 has 11 positions; at time=0, it is at position 0."
).each.with_index { |line, i|
  size, pos = line.scan(/ \d+/).map(&:to_i)
  
  while (i+pos+t) % size != 0
    t += step
  end
  
  step *= size
}

p t-1