solvethis

It’s a Puzzlement

By Jon Evans

Forklift Clearance

F

or clearance planning, model a forklift’s location on a warehouse floor that measures 30 meters by 20 meters using a single reference point as its center. Relative to the scale of the warehouse, treat that reference point as a mathematical point that may lie anywhere on the floor with equal likelihood.

Let M be the Euclidean distance from the reference point to the nearest wall. Derive a general formula for the expected value E[M] in an L × W rectangle (L > 0, W > 0). Evaluate E[M] for the 30 × 20 warehouse. A square warehouse with the same floor area has side length √600 = 10√6. Is E[M] for the square larger than, smaller than, or equal to the 30 × 20 value? Compute the square’s expectation and compare.

A forklift is parked inside a large warehouse filled with stacked white boxes on pallets and metal shelving.

The Programmer’s Eternal Loop

Owing to some confusion among draft versions, an earlier statement of this puzzle is the one that made it into print. In that printed version, the unexamined code grows each second by 1% of its current length (rather than by the square root of its length). We solve that printed statement here and then offer the intended version as an open challenge.

Printed version (1% growth). Lila begins with 1,000,000 unexamined lines and a review rate of 100 lines per second. Each second she reviews code at her current rate; the remaining unexamined code then grows by 1%; and her review rate increases by the natural logarithm of the product of examined and unexamined lines (with no increase while nothing has yet been examined).

She never finishes. Exponential growth at 1% per second continually enlarges the backlog in proportion to its size, while her rate receives only a logarithmic boost each second. The gap between the growth she must overcome (1% of the unexamined lines) and her review speed therefore widens without bound, and the unexamined count diverges.

Intended version (open challenge). The statement originally intended — and preserved in the editorial archive — is more interesting. It is the same setup, except that every second the unexamined code grows by the square root of its current length (not by 1%). Lila’s initial rate is still 100 lines per second, and that rate still increases each second by the logarithm of the product of examined and unexamined lines; she still starts with 1,000,000 lines left to review. Will she ever finish debugging the entire script? If so, how long does it take? Extra credit: If instead the code grows by r% per second for an arbitrary positive r, for which values of r does she finish in finite time, and what is the time required?

Know the answer to the intended version? Send your solution to ar@casact.org.

Solutions to the printed version were submitted by Bob Conger, Jonathan Hunt, Jerry Miccolis, Samiksha Padiyar, Natalie Ramirez, and Rob Thomas..

Digital graphic of a programmer's hands on a keyboard surrounded by flowing data and code.
Know the answer? Send your solution to ar@casact.org.