1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
input = DATA.read.scan(/([LR])(\d+)/)
  .map { [_1, _2.to_i] }

points = [50]

input.each do |dir, distance|
  sign = case dir
         when ?L then -1
         when ?R then 1
         else fail
         end
  # part one
  # points << (points.last + distance * sign) % 100

  distance.times do
    points << (points.last + sign) % 100
  end
end

pp points.count(&:zero?)

__END__