Advent of Code, day 2 done.

This one felt familiar. I remember previous years having digit grouping problems like this before. I remembered that doing it arithmetically in most cases performs much better than a string comparison, so that's how I approached this initially.

Out of curiosity, I also converted each ID into a string and did a chunk-wise comparison, and it performed really well, taking only about 50% more time than the arithmetic solution. I'm sure my arithmetic solution could be faster, though. I initially used a String to hold the id, then switched to a stack array, but that didn't improve the speed at all. Glibc's allocator is really fast these days.

#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day2 #AdventOfCode2025Day02 #Day2 #Day02 #Rust #RustLang #Programming #Coding

2025/src/bin/day02.rs at 77f87f1b1cba591537108920857852ebe6a0ef97e4fc7cabc655d523b0216c26

2025

AxFive