mirror of
https://github.com/onyx-and-iris/aoc2025.git
synced 2025-12-08 11:47:47 +00:00
33 lines
510 B
Ruby
Executable File
33 lines
510 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
class Main
|
|
def run
|
|
current = 50
|
|
count = 0
|
|
|
|
$stdin.each_line do |line|
|
|
direction, magnitude = line[0], line[1..].to_i
|
|
|
|
while magnitude > 0
|
|
case direction
|
|
when "R"
|
|
current = (current + 1) % 100
|
|
when "L"
|
|
current = (current - 1 + 100) % 100
|
|
end
|
|
|
|
if current == 0
|
|
count += 1
|
|
end
|
|
|
|
magnitude -= 1
|
|
end
|
|
end
|
|
|
|
puts count
|
|
end
|
|
end
|
|
|
|
Main.new.run
|