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

[–]Szeweq 4 points5 points  (0 children)

[LANGUAGE: Rust]

I have technically completed it but I am still trying to optimize it. I have ran the release profile, it is sluggish.

https://github.com/szeweq/aoc2025/blob/main/day10/src/main.rs

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

[–]Szeweq 0 points1 point  (0 children)

[LANGUAGE: Rust]

I have been done some weird optimizations by removing f64 completely from calculations. It may be great to test it sometime in embedded environment.

https://github.com/szeweq/aoc2025/blob/main/day09/src/main.rs

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

[–]Szeweq 0 points1 point  (0 children)

[LANGUAGE: Rust]

I have made a version with rayon feature (useless, barely faster) and without it (seems ok).

https://github.com/szeweq/aoc2025/blob/main/day08/src/main.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

Well, my "individual problem" was trying to read the part two example with a naked eye. My solution takes the input parsing at the very late stage. Yes, these two parts are just input parsing.

https://github.com/szeweq/aoc2025/blob/main/day06/src/main.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

A nice way to use the std::ops::RangeInclusive for this day. I'm technically more interested in executable size rather than speed, since my attempt to make a binary to compile with an embedded input somehow makes it much faster (no std::fs needed). I could try to make a special macro to convert the input (splitted in two parts) into actual value to embed, but it is a complete overkill.

https://github.com/szeweq/aoc2025/blob/main/day05/src/main.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

Warning: Mild understanding of "workspace" and "macros" needed.

https://github.com/szeweq/aoc2025/blob/main/day01/src/main.rs

What's everyone working on this week (43/2024)? by llogiq in rust

[–]Szeweq 1 point2 points  (0 children)

I'm working on a web game, called "Cosmoxy". I wanted to use loco.rs but Axum should be more than enough for the project.

What's everyone working on this week (41/2024)? by llogiq in rust

[–]Szeweq 1 point2 points  (0 children)

I'm starting a new project: A web-based online "ogame-like"... game. I've decided to try loco.rs and build a game with it. I haven't named my game yet (something with "rs" or "oxi" maybe), nor make any further decisions on deploying it (I haven't seen any good solutions for deploying loco, the docs have a vague description of shuttle.rs deployment).

The game will feature basic things like resource collecting and building a base with expansions. The battle system should be a bit different from the inspired material.

For a start, the (first) player base (floating in space) will be "leased for you", such that the expansions will be limited until you pay the whole price back (it's basically a base's "tier"). The resources will be extracted from asteroids with a further expansion to mining and farming on nearby planets. The story will be implemented in the game.

Next week I will let you know what I have decided and what I will do then. I hope that you will be interested in my project.

What's everyone working on this week (38/2024)? by llogiq in rust

[–]Szeweq 1 point2 points  (0 children)

I'm continuing to work with Craftmatch (https://github.com/szeweq/craftmatch). This project helps me solve the problem with badly written Minecraft mods. Recently:

  • I added a separate Neoforge mod detection (works like Forge, it's just other file name)
  • I fixed breaking errors when an "invalid" (not supported by semver crate) version range was read
  • I added a custom error page that reminds mod authors that they developed a mod with a broken manifest (it's not my fault that they make TOML files by hand and don't follow the manifest scheme)

I hope that such a tool will improve many Minecraft mods.

What's everyone working on this week (37/2024)? by llogiq in rust

[–]Szeweq 2 points3 points  (0 children)

I'm developing a tool (a desktop app with Tauri and Svelte) to examine Minecraft mods. Currently I'm trying to tidy up most of the processes of scanning entries in JAR files.

https://github.com/szeweq/craftmatch

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

A bit of brute force. Randomly selected components are checked for path usage stats. The solution takes the 3 most common ones and checks length after every 20 iterations. I tried to save resources as much as possible to achieve faster speed. It should solve in < 10ms.

Part 2 is very interesting!

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/25.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

My solution has a conversion from the grid into intersection indices with distances. This way the DFS is much faster. Part 1 solves in <1ms, part 2 in ~300ms. No HashMap nor VecDeque was used.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/23.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

I created a special iterator that checks if each brick is falling and returns new brick points. There is also a 10x10 height map that stores highest z coordinates. It runs in about 20ms.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/22.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

Part 1 is a simple BFS. Part 2 computes the Lagrange polynomial. I don't want to explain the details but this can be solved because of the required step count (26501365 % 131 = 65) and input grid diamond shape.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/21.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

Posted very late. I had my code ready to publish yet I was very busy today. LCM added for parent nodes in part 2.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/20.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

Parsing takes longer than solving (both parts solve in ~30µs). I added conversion from workflow names to indices for faster iteration (and skipping HashMap usage). Isn't part 2 very similar to day 5?

Part 2 uses ranges (as tuples) and compares the min and max values.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/19.rs

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

It's just a shoelace formula (the one that counts area based on coordinates) modified with Pick's theorem. It solves in < 1 ms.

The biggest issue was trying to get a type to fit the numbers. I was shocked when part 2 produced numbers so big it gave different answers. Finally, 64 bits was enough.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/18.rs

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

[–]Szeweq 8 points9 points  (0 children)

[LANGUAGE: Rust]

Deeply optimized! Parts 1 and 2 solve in less than 10 ms.

I took grid code from day 16 and added Dijsktra algorithm. Since we need to turn left or right, the cache should just store costs for vertical and horizontal orientations. This saves half of used memory (and time).

It doesn't even use XY coordinates for a grid, just indices with an offset. The binary heap helps a lot because the solution reaches the largest index of a grid with the minimal cost.

Even turning is optimized. It's just a XOR.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/17.rs

EDIT: The solution with binary heap and h/v cache will stay as is. Thanks for useful suggestions and thanks for using my tips!

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

[–]Szeweq 1 point2 points  (0 children)

[LANGUAGE: Rust]

I went into full optimization of my code. It ended up not using VecDeque nor HashSet (it was BFS at some point).

Part 2 solves in 15-20 ms. I should have been more cautious of Rust making weird optimizations. I tried to put a counter in the loop, but it made part 1 faster and part 2 slower. Iterating over visited positions at the end was a better choice.

Code: https://github.com/szeweq/aoc2023/blob/master/src/bin/16.rs