Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Robotic Package Sorting Function

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.


📦 Sorting Rules

A package is classified using the following criteria:

Bulky

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

Heavy

A package is considered heavy if:

  • Mass is greater than or equal to 20 kg

🗂️ Dispatch Logic

Condition Result
Not bulky and not heavy STANDARD
Bulky or heavy SPECIAL
Bulky and heavy REJECTED

📁 Project Files

├── sort.js # JavaScript implementation with test runner

├── sort.py # Python implementation with test runner

└── README.md


▶️ Running the JavaScript Version

Requirements

  • Node.js (LTS recommended)

Run

node sort.js

Output

The script runs predefined test cases and prints results such as:

Test 1: PASS → Expected: STANDARD, Got: STANDARD

▶️ Running the Python Version

Requirements

Python 3.8 or higher

Run

python sort.py

Output

The script runs predefined test cases and prints results such as:

Test 1: PASS → Expected: STANDARD, Got: STANDARD

🧪 Test Coverage

  • 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

👤 Author

Jack Storment

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages