48
SOLUTION MEGATHREAD-🎄- 2021 Day 11 Solutions -🎄-(self.adventofcode)
submitted 4 years, 1 month ago* (edited 1 hour, 2 minutes after) by daggerdragon to /r/adventofcode (134.8k)
NEW AND NOTEWORTHY
[Update @ 00:57]: Visualizations
- Today's puzzle is going to generate...
since 4 years, 1 month ago
9 of 9
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


Python 3 - Minimal readable solution for both parts [GitHub]
[removed] content loading...
Does it actually work reliably? (Aren't complex numbers in python floats? And floats as indices are prone to off-by-rounding equality issues)
Doubles can represent the same number of integers as a ~54-bit signed integer type. In other words, it sholud be fine.
I'm not talking about the amount, I'm talking about the fact that `7/3/3/3*3*3*3` is not `7`, bit `6.9999999`. Rounding errors. You can't reliably do equality comparisons on floats.
Multiplication and addition of integers are exact (if the result is representable). Division should also work if the numbers are divisible.
Yes you are right! My bad. Just re-read IEEE spec and you are absolutely right.
I think the numbers I had in my head are 0.1, 0.2, 0.3 and similar. Those are not representable by IEEE floats.
Great idea then! Nice thinking outside the box.
A dict with an (x,y) tuple as key is a nice way to represent a grid. I think it is more readable than complex numbers. Check out this solution from day 9.
I'm not sure it actually saves any space or anything though? (At least the way it's used here.)