this post was submitted on 01 Dec 2025
47 points (100.0% liked)

Advent Of Code

1154 readers
39 users here now

An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Everybody Codes is another collection of programming puzzles with seasonal events.

EC 2025

AoC 2025

Solution Threads

M T W T F S S
1 2 3 4 5 6 7
8 9 10 11 12

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 2 years ago
MODERATORS
 

Day 1: Secret Entrance

Megathread guidelines

  • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
  • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

FAQ

you are viewing a single comment's thread
view the rest of the comments

So, obviously the bot didnt work, thanks Ategon for covering :D

Here is the dumb solution for pt2, everyone can share in my shame:

#[test]
    fn test_2025_1_part2() {
        let input = std::fs::read_to_string("input/2025/day_1.txt").unwrap();
        let turns = input
            .lines()
            .map(|line| {
                let value = line[1..].parse::<i32>().unwrap();
                if line[0..1] == *"L" {
                    -value
                } else {
                    value
                }
            })
            .collect::<Vec<i32>>();
        let mut zero_ctr = 0;
        let mut pos = 50;
        for turn in turns {
            print!("{pos}->");

            let mut zero_passes = 0;
            if turn > 0 {
                for _ in 0..turn {
                    pos += 1;
                    if pos == 100 {
                        pos = 0;
                        zero_passes += 1;
                    }
                }
            } else {
                for _ in 0..-turn {
                    pos -= 1;
                    if pos == 0 {
                        zero_passes += 1;
                    }
                    if pos == -1 {
                        pos = 99;
                    }
                }
            };
            println!("{turn}->{pos}: {zero_passes}");
            zero_ctr += zero_passes;
        }
        println!("zero ctr: {}", zero_ctr);
    }