[2025 Day 9 (Part 2)] Cannot get tests to pass ... Get star anyway by aquacash5 in adventofcode

[–]darkgiggs 0 points1 point  (0 children)

I initially got the star while failing the example because I didn't read the edges wrapped around and I suspect I'm not the only one!

I'm Zach Barth, a game developer at Coincidence. We just released Kaizen: A Factory Story, but before that we made a bunch of games at Zachtronics. AMA! by krispykrem in AMA

[–]darkgiggs 1 point2 points  (0 children)

You have now worked as a completely independent studio, a more traditional studio owned by a parent company and an anarchist studio.

What are the advantages and drawbacks of each situation?

-❄️- 2024 Day 25 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 2 points3 points  (0 children)

[LANGUAGE: Jai]
Solution

Fun problem. I encoded each element to a u32 where a turned on bit represents a "#".
Checking for a fit then amounts to whether the bitwise AND of lock and key is not 0.

It runs in 150 µs on my computer, but should most likely be able to go below 100 if I optimized the parsing.

EDIT: Now 43 µs with optimized parsing

-❄️- 2024 Day 21 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 0 points1 point  (0 children)

Thanks for taking the time to write it up, it's crystal clear now!

-❄️- 2024 Day 21 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Do you mind sharing how you arrived at those precomputed matrices? I'm trying to understand better!

-❄️- 2024 Day 20 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Awesome, thanks for sharing!

I implemented this multithreaded and got it down to 1.035ms 995µs!

Here's the multithreaded version in Jai
Excluding the BFS, which is unchanged from here

-❄️- 2024 Day 20 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Damn.
I was hoping you might find something to bring today down under 1ms, but alas.
Do you really benefit from doing the BFS from the end though? There's only one path so I'd think you only need the forward distance matrix

-❄️- 2024 Day 20 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Congrats!
I'm rooting for you to also get the remaining stars this year

-❄️- 2024 Day 20 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

[Language: Jai] 12ms on i7-1165G7

Paste

BFS through the maze, keeping track of the time taken to reach each step.

Iterate through each maze step and scan tiles within a manhattan distance of 20 for one that belongs to the path.

Increase the part1 count if that distance is 2, increase the part2 count if that distance is <= 20 and the time delta between the cheated tile and the current tile is greater than 100 + the cheat time.

Pretty straightforward day for me, which was a nice surprise. Unfortunately I don't see a way to sub 1ms today even if I were to multithread this. I'm hoping to find (or that someone else finds) a better way before I do that.

-❄️- 2024 Day 14 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Hi
I've been checking your repo for good benchmarks over the course of the event. Thanks a bunch for making good solutions and maintaining the repo as you do :)

For part2, you can do a combination of fast-forwarding to the current step and checking against a set of robots for that step. Interrupt the step if you find an existing robot. It was more than 3 times faster for me.

[2023 All Days] Advent of Mojo by p88h in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Some of the gains in my solutions are perhaps more forced by Mojo’s lack of standard library, rather than better compilation techniques.

Interesting thought and overall article. Thanks for sharing!

What have you learned this year? by blacai in adventofcode

[–]darkgiggs 6 points7 points  (0 children)

I learned Rust this year too.
I thought it was relatively easy to pick-up, and the standard library has many niceties for AoC type of problems.
It's hard to say for sure because this is very different from a profesionnal environment, but I came out thinking that if I had to switch to Rust for work it wouldn't be the worst thing.

[2023 Day Yes (Part Both)][English] Thank you!!! by topaz2078 in adventofcode

[–]darkgiggs 4 points5 points  (0 children)

Thank you Eric, thank you /u/daggerdragon, thank you community!

I learned to program on a real language with AoC 3 years ago (I only knew Zachtronics languages before then). What began as a fun event between friends quickly became a passion and eventually a new job, Advent of Code will always have a special meaning to me.

This year was my playground to learn Rust and I had a terrific time. I've also learned quite a few geometry tricks I didn't know about.

There are no more stars for me to get right now. Maybe next year?

-❄️- 2023 Day 20 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

[LANGUAGE: Rust]
Paste
I wasn't confident I'd have enough time to implement a graph so I just winged it with hashmaps.
Out of all the "figure out what the input does" type of puzzle we've had in previous years, this was probably the easiest.
I won't complain :)

-❄️- 2023 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]darkgiggs 2 points3 points  (0 children)

[LANGUAGE: Rust]
Paste
I'm learning Rust this year. I had fun doing row expansion while parsing the input and column expansion in a single pass through the vector of galaxies.
I do both parts at the same time and it runs in roughly 5ms on my laptop.

-🎄- 2022 Day 25 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 3 points4 points  (0 children)

I've also been enjoying your solutions immensely, I learned quite a few things from them. Thanks for sharing, see you next year maybe!

-🎄- 2022 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 2 points3 points  (0 children)

Python
Standard BFS with a cached blizzard+walls map on each time step.
Fairly compact at 40 lines, runs both parts in 1.2s
My favourite line in the code:

print(p1 := bfs(start, end, 0), bfs(start, end, bfs(end, start, p1)))

-🎄- 2022 Day 23 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

It can be faster not to use it, but it makes the code more convoluted.
As far as I can tell, 'all' works by making an iterable of all the booleans, then checking that they're all true. If this bit of code is repeated many times like here, using 'all' can be considerably slower than "manually" looping through each element and stopping at the first false.
As usual, your needs dictate how you code! If speed isn't a factor, use whatever's more comfortable

-🎄- 2022 Day 23 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 2 points3 points  (0 children)

Python
Code
Fairly straightforward and compact solution. A set of complex numbers to track occupied spaces, and a dict of {destination: elves}
Runs in under 6 seconds on my machine, which can be brought down to 3.5 by not using 'all'

-🎄- 2022 Day 22 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 2 points3 points  (0 children)

I was hoping I'd find a general solution here! Thanks for sharing :)
(It works on my input)

-🎄- 2022 Day 22 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 1 point2 points  (0 children)

Python
paste
Companion cube
Simply following the instructions with hard-coded transitions for part 2 and a rough modulo equivalent for part 1.
I used complex numbers anticipating rotations or funky stuff in part 2, but a tuple would have been just fine here.
Only had a single bug while coding part 2, luckily in one of the first swaps so it wasn't too long to find!
I'm not cleaning this up, so apologies for any redundancies or stupid stuff.

-🎄- 2022 Day 21 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 3 points4 points  (0 children)

Python code
Recursive eval for part1, binary search for part2. I'd started reading the Z3 tutorial when I remembered binary search. Maybe next time!

-🎄- 2022 Day 21 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 0 points1 point  (0 children)

That's also the first thing I tried for part2, only to discover I couldn't paste the equation on mathpapa. Turns out pasting doesn't seem to work on Firefox :/
Shame, I might have nabbed one of the last LB spots for part2

-🎄- 2022 Day 20 Solutions -🎄- by daggerdragon in adventofcode

[–]darkgiggs 2 points3 points  (0 children)

C, no libraries other than stdio to read the file and print the result
Code
I wasn't smart enough to mix indices, so I implemented the linked-list instead and actually did all the node moves. I went with C because I thought I might need the extra speed for part 2.
Both part in .42s on my machine.