I feel like im soo close but I cant even solve part 1.

Where did I go wrong??
https://git.gay/ChaoticLeah/advent-of-code-2025/src/branch/master/src/3/main.rs

#AdventOfCode
ChaoticLeah/advent-of-code-2025

Surely I will see this all the way through

git.gay
@ChaosKitsune try an input of 1111111119, I think that will show where it goes wrong.
@ChaosKitsune max_by_key selects the last maximum value, not the first. (I used a very similar approach.)
@decivex unfortunately I found this out just before the comment but thanks for the reply.

Now ive switched to some weird .fold method. Is there a way to just tell rust to select the first max instead of the last or no?
@ChaosKitsune The way I did it was by using a tuple of (value, -(index as isize)) as the key for max_by_key.
@decivex huh is that code somewhere public? Im curious now. That does sound easier
day03/src/common.rs · master · decivex / Advent of Code 2025 · GitLab

GitLab.com

GitLab
@ChaosKitsune oh, scratch that.. that input should work, but looks like you hit the same problem I did... Try 9111111111190
@JustinAzoff I found the problem: Rusts .max functions don't guarantee it taking the biggest first occurrence. Meaning in cases where you have [ 1, 2, 8, 8, 3 ] It will probably grab the 2nd 8 and for the problem means the biggest number we can get is 83 which in reality it should be 88

I struggled for way too long on this.
@ChaosKitsune yeah, the docs say it returns the last occurrence. I fixed it in my solution by sticking a .rev() after enumerate.. which makes it find the first
@JustinAzoff ah yeah I was considering reversing it somehow but it seemed weird.

Also yeah I didnt have the docs up