Skip to content

Instantly share code, notes, and snippets.

@ROFISH
Last active December 6, 2025 01:37
Show Gist options
  • Select an option

  • Save ROFISH/d5f5ccd8b4d1b6495239ae7f52ee76b8 to your computer and use it in GitHub Desktop.

Select an option

Save ROFISH/d5f5ccd8b4d1b6495239ae7f52ee76b8 to your computer and use it in GitHub Desktop.
Advent of Code 2025
dial = 50
password = 0
File.read("./input.txt").split("\n").each do |dial_movement|
movement, amount = dial_movement[0],dial_movement[1..-1].to_i
amount *= -1 if movement == "L"
dial += amount
dial -= 100 while dial > 99
dial += 100 while dial < 0
password += 1 if dial == 0
end
puts "Password is #{password}"
dial = 50
password = 0
File.read("./input.txt").split(/\r?\n/).each do |dial_movement|
movement, amount = dial_movement[0],dial_movement[1..-1].to_i
amount *= -1 if movement == "L"
dial = 100 if dial == 0 && movement == "L"
dial += amount
while dial > 100
dial -= 100
password += 1
end
while dial < 0
dial += 100
password += 1
end
dial = 0 if dial == 100
password += 1 if dial == 0
end
puts "Password is #{password}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment