Unable to load image

rDrama Advent of Code Day 10: Hoof It

https://adventofcode.com/2024/day/10

I hope this fine morning finds you well, saars.

The word of the day is: graphs!

Rdrama leaderboard. Invite code: 632268-30587026, you need to log in first.

Announcement post with useful links.

@Merryvann please pin this and unpin Day 9.

17
Jump in the discussion.

No email address required.

I spent so long optimising day 6 that I can't even see matrices any more, only graphs.

Sucks the paths were so short there was no point in edge contraction :marseygiveup:

https://i.rdrama.net/images/17338415539869306.webp

836.24µs runtime

Bonus content, came up with a generic path counter that could accept HashSet or Vec:

fn count_paths<T>(init: T, graph: &Graph) -> usize
where
    T: IntoIterator<Item = usize> + FromIterator<usize>,
    T::IntoIter: ExactSizeIterator,
{
    (0..9).fold(init, |acc, _| {
        acc.into_iter()
            .flat_map(|n| graph.get(&n).unwrap().clone())
            .collect::<T>()
    })
    .into_iter()
    .len()
}

Such a beautiful concise language :tayadmire:

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.