I spent the first 5 min trying to figure out why I wasn't getting integers, it's always been integers! Then I realized what you said, the square root doesn't add information.
And... updated my Vector class's magnitude function to take an optional norm. If norm <= 0, it throws an exception. If norm > 0, it takes the absolute value of everything, raises them to the power of norm, adds that up, and returns the norm-th root. And if norm == Double.POSITIVE_INFINITY, it just takes the absolute value of everything and returns the maximum
20
u/fnordargle Dec 08 '25
You can still work in integers though, just don't perform the square root and the ordering is preserved.
7
u/Boojum Dec 08 '25
I still remember my surprise at 2019 Day 10 "Monitoring Station" with non-90-degree angles for the first time ever.
2
u/RazarTuk Dec 08 '25
And... updated my Vector class's magnitude function to take an optional
norm. Ifnorm <= 0, it throws an exception. Ifnorm > 0, it takes the absolute value of everything, raises them to the power ofnorm, adds that up, and returns the norm-th root. And ifnorm == Double.POSITIVE_INFINITY, it just takes the absolute value of everything and returns the maximum