Files
advent-of-code/2025/01.rb
2025-12-01 08:34:10 -08:00

26 lines
330 B
Ruby

input = File.readlines('input/01')
pos = 50
p1 = 0
p2 = 0
input.each do |line|
dir = line[0]
n = line[1..].to_i
(1..n).each do
if dir == 'R'
pos = (pos - 1 + 100) % 100
else
pos = (pos + 1) % 100
end
if pos.zero?
p2 += 1
end
end
if pos.zero?
p1 += 1
end
end
puts p1
puts p2