A robotic arm dispatch controller that sorts packages into the correct stacks based on their physical dimensions and mass. Built as a solution to the Thoughtful Automation factory routing problem.
In an automated factory, packages arrive on a conveyor belt and must be routed to different handling stacks based on their size and weight. The sorting algorithm determines whether each package can be handled automatically, requires special manual handling, or must be rejected entirely.
Normal packages that can be handled automatically by the robotic arm.
Packages that are too heavy OR too bulky - requires manual handling.
Packages that are both heavy AND bulky - cannot be safely processed.
A package is bulky if:
A package is heavy if:
| Bulky | Heavy | Stack |
|---|---|---|
| No | No | STANDARD |
| Yes | No | SPECIAL |
| No | Yes | SPECIAL |
| Yes | Yes | REJECTED |
Try it yourself - adjust the sliders to see how packages are classified in real-time.
Normal handling - automated
The sorting algorithm is a pure function with full test coverage. It takes package dimensions and mass as inputs and returns the appropriate stack classification.
function sort(width, height, length, mass): Stack {
const volume = width * height * length;
const isBulky = volume >= 1_000_000
|| width >= 150
|| height >= 150
|| length >= 150;
const isHeavy = mass >= 20;
if (isBulky && isHeavy) return 'REJECTED';
if (isBulky || isHeavy) return 'SPECIAL';
return 'STANDARD';
}View the full source and tests on GitHub