~/boss / lone-smith

Shortest job first (min-heap)

The Lone Smith

One anvil, a queue of orders. Always forge the quickest order that's already here.

Loading the fight…

How to beat it

Orders arrive over time. Whenever the anvil is free, look only at the orders that have arrived and forge the shortest one; on a tie, the lower number goes first. Nothing waiting? Jump the clock to the next arrival. A min-heap keyed on (length, number) hands you that order in log n steps.

Now the real boss

Interviews ask for the code. Watch it run, then write it yourself, tested in Python, C++ or Java.

On your phone? Writing code is easier on a laptop: open bossfight.dev/problems/single-threaded-cpu there. Sign in with your email to keep your progress on every device.

More bosses

esc