Last active
December 6, 2025 01:37
-
-
Save ROFISH/d5f5ccd8b4d1b6495239ae7f52ee76b8 to your computer and use it in GitHub Desktop.
Advent of Code 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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