3 ms·
Actually there's a slight optimization available. Why ten floors? Because basically what we are doing is establishing a most significant digit - the tens place,
by numlocked 14y ago
Actually there's a slight optimization available. Why ten floors? Because basically what we are doing is establishing a most significant digit - the tens place, then the ones place. This works because 100 is a square number (10*10). But what if there were 64 floors? Then, to do the same thing (but in base 8), we'd drop every 8 floors. We can account for this as we drop by treating all floors above as a fresh tower and rounding to the nearest square number: Drop on floor 10 (90 floors remain - 81 is closest square, so now only go up 9 floors), drop on 19 (81 floors remain, go up 9 again), drop on 28 (72 floors remain, 64 is closest square, go up 8), etc, etc.