Re:Locating the Source of a Mysterious Beep
by aizk on Monday November 09, 2026 @10:35PM
(#50435750)
It's O(logn) but you haven't accounted for how heavy each item in the array of n is.
[ Parent
| on HN ]
Re:Locating the Source of a Mysterious Beep
by tonyarkles on Monday November 09, 2026 @11:04PM
(#50435927)
Lol classic “ignore the constant factor” gotcha when using Big-O.
Re:Locating the Source of a Mysterious Beep
by aizk on Tuesday November 10, 2026 @02:15PM
(#50444859)
This is a pretty good real world example to show off how O(n) can't always tell the full story.
Re:Locating the Source of a Mysterious Beep
by mauvehaus on Monday November 09, 2026 @11:06PM
(#50435939)
This is true, but it probably isn't a box of books that's beeping.
I also feel like ordering the moves by lightest box first is reasonable as a real-world optimization.
Re:Locating the Source of a Mysterious Beep
by Spare_account on Tuesday November 10, 2026 @05:15AM
(#50438240)
Typically, the heavy boxes are at the bottom too; to some extent, the piles will already be sorted by weight.
Re:Locating the Source of a Mysterious Beep
by kelseyfrog on Monday November 09, 2026 @11:34PM
(#50436098)
If you randomly index them and there's enough of them then on average the partitions average out.
Re:Locating the Source of a Mysterious Beep
by StilesCrisis on Tuesday November 10, 2026 @07:55AM
(#50439662)
You can just move the lightest half of the boxes each time.
Re:Locating the Source of a Mysterious Beep
by dolmen on Tuesday November 10, 2026 @10:23AM
(#50441681)
A few additional constraints:
- the boxes are stacked
- the heavy boxes are at the bottom of a stack, and you can't stack a heavy box on top of a light one
- boxes aren't the same size
- some boxes are open, so must be put on top
- storage space and height are limited