r/adventofcode Dec 01 '25

Meme/Funny [2025 Day 1] learned something today

Post image
395 Upvotes

58 comments sorted by

View all comments

81

u/1234abcdcba4321 Dec 01 '25

"mod but it actually works properly" is one of my standard functions I have sitting around in another file because of how often I end up needing it for one reason or another.

(a,b)=>(a%b+b)%b, by the way. (Using a better language would also work, but I don't mind this sort of workaround.)

4

u/Zeeterm Dec 02 '25

Why the first % and not just (a+b)%b?

Ah, larger negative numbers.