Koko Eating Bananas, two ways

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Cost

Work done so far, and how the two solutions compare

Piles

Each block = one hour of eating k bananas

Keyboard: ← → step, Space play or pause. Up to 8 piles of 1–30 bananas, and h from the number of piles up to 99 (h is never smaller than the number of piles, so k = max(piles) always works). Java and C++ compute ⌈p / k⌉ as p / k plus 1 if there is a remainder, which avoids floating point and overflow.