This project implements a package-sorting function used in a robotic automation system.
The function determines whether a package should be dispatched to the STANDARD, SPECIAL, or REJECTED stack based on its dimensions and mass.
The solution is provided in JavaScript and Python, each with a built-in test runner for immediate execution and verification.
A package is classified using the following criteria:
A package is considered bulky if any of the following conditions are met:
- Volume (width × height × length) is greater than or equal to 1,000,000 cm³
- Width, height, or length is greater than or equal to 150 cm
A package is considered heavy if:
- Mass is greater than or equal to 20 kg
| Condition | Result |
|---|---|
| Not bulky and not heavy | STANDARD |
| Bulky or heavy | SPECIAL |
| Bulky and heavy | REJECTED |
├── sort.js # JavaScript implementation with test runner
├── sort.py # Python implementation with test runner
└── README.md
- Node.js (LTS recommended)
node sort.jsThe script runs predefined test cases and prints results such as:
Test 1: PASS → Expected: STANDARD, Got: STANDARD
Python 3.8 or higher
python sort.pyThe script runs predefined test cases and prints results such as:
Test 1: PASS → Expected: STANDARD, Got: STANDARD
-
Both implementations include test cases covering:
-
Standard packages
-
Bulky packages by volume
-
Bulky packages by dimension
-
Heavy-only packages
-
Packages that are both bulky and heavy
-
Edge cases at exact threshold values
-
Input validation for negative values
Jack Storment