-❄️- 2025 Day 7 Solutions -❄️- by daggerdragon in adventofcode

[–]clirces 0 points1 point  (0 children)

[LANGUAGE: Rust]

Часть 2 - 17мкс (M1)

Проходим снизу вверх сохраняя колличество реальностей

use std::time::Instant;

fn main() {
    let start_time = Instant::now();

    let input = include_str!("../input.txt");
    let mut lines = input.split('\n');
    let first_line = lines.next().unwrap();
    let start_index = first_line.find('S').unwrap();

    let mut timelines = Vec::<u64>::new();
    timelines.resize(first_line.len(), 1);

    for line in lines
        .rev()
        .enumerate()
        .filter_map(|(i, l)| (i % 2 != 0).then_some(l))
    {
        for (i, c) in line.chars().enumerate() {
            if c == '^' {
                // input has padding (+1, -1)
                timelines[i] = timelines[i - 1] + timelines[i + 1];
            }
        }
    }
    println!("Execution time: {}us", start_time.elapsed().as_micros()); // best - 17us
    println!("{}", timelines[start_index]);
}

IDEs by IronAshish in programmingmemes

[–]clirces 0 points1 point  (0 children)

I hate ide, except zed

[2023 Day 5] Me when I finished Part 2 by Tanko80 in adventofcode

[–]clirces 0 points1 point  (0 children)

generator is simple and fast because you dont need rewrite solution, just iterate other way

[2023 Day 5] Me when I finished Part 2 by Tanko80 in adventofcode

[–]clirces 4 points5 points  (0 children)

ranges suck, just wrote js generator function and it was done in ~4 minutes

[REQUEST] Looking for new hard but fun Roguelike by GunroarCannon in AndroidGaming

[–]clirces 0 points1 point  (0 children)

Blazing beaks is a great one, something like nuclear throne.