Last active
December 1, 2025 16:28
-
-
Save peteryates/b8e5db8b1653916c5811be5ed8addce4 to your computer and use it in GitHub Desktop.
AOC 2025 day 1
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
| wheel = (0..99).to_a | |
| wheel.rotate!(50) | |
| data = File.read("input.txt").chomp.split("\n") | |
| puts "Part 1" | |
| part_1_hits = 0 | |
| part_1_wheel = wheel.dup | |
| current_position = part_1_wheel.first | |
| data.each do |turn| | |
| direction, clicks = turn[0].to_s, turn[1..].to_i | |
| adjustment = direction == "L" ? -clicks : clicks | |
| current_position = part_1_wheel.rotate!(adjustment).first | |
| part_1_hits += 1 if current_position == 0 | |
| end | |
| puts "=> #{part_1_hits}" | |
| puts "Part 2" | |
| part_2_wheel = wheel.dup | |
| current_position = part_2_wheel.first | |
| part_2_hits = 0 | |
| part_2_passes = 0 | |
| data.each do |turn| | |
| direction, clicks = turn[0].to_s, turn[1..].to_i | |
| adjustment = direction == "L" ? -1 : 1 | |
| clicks.times do |i| | |
| current_position = part_2_wheel.rotate!(adjustment).first | |
| break if i == clicks - 1 | |
| part_2_passes += 1 if current_position == 0 | |
| end | |
| part_2_hits += 1 if current_position == 0 | |
| end | |
| puts "=> #{part_2_hits + part_2_passes}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment