This project is designed to implement a robust package sorting system for Thoughtful's robotic automation factory. The purpose of the system is to classify packages into different stacks (STANDARD, SPECIAL, or REJECTED) based on their dimensions and weight.
The main module contains a function sort(width, height, length, mass)
that determines the appropriate stack for a package according to the following criteria:
- STANDARD: Packages that are neither bulky nor heavy.
- SPECIAL: Packages that are either bulky or heavy, but not both.
- REJECTED: Packages that are both bulky and heavy, or have invalid dimensions/mass.
- A package is bulky if:
- Its volume (Width × Height × Length) is ≥ 1,000,000 cm³, or
- Any of its dimensions is ≥ 150 cm.
- A package is heavy if its mass is ≥ 20 kg.
├── src/
│ ├── main/
│ │ └── kotlin/org/example/ThoughtfulAutomation.kt
│ └── test/
│ └── kotlin/org/example/ThoughtfulAutomationTest.kt
├── README.md
└── build.gradle.kts
- Main Module: The implementation of the sorting logic is in
src/main/kotlin/org/example/ThoughtfulAutomation.kt
. - Test Suite: Unit tests are available in
src/test/kotlin/org/example/ThoughtfulAutomationTest.kt
.
Ensure you have the following installed:
- JDK: Version 11 or higher
- Gradle: Version 7.0 or higher
- Any preferred IDE such as IntelliJ IDEA.
-
Clone the repository:
git clone https://github.com/jnoecker/ThoughtfulAI.git cd PackageSorter
-
Build the project (optional step to verify the build system works):
./gradlew build
-
Run the main function:
- This can be done by executing the
main
application directly from your IDE. - Alternatively, use the
run
task:./gradlew run
- This can be done by executing the
Unit tests are included to verify the correctness of the sorting logic. Follow these steps to execute the test suite:
- Run tests using Gradle:
./gradlew test
Here’s how the sort()
function works with sample inputs:
val stack1 = ThoughtfulAutomation.sort(100, 100, 100, 5) // Output: "STANDARD"
val stack2 = ThoughtfulAutomation.sort(200, 100, 100, 5) // Output: "SPECIAL"
val stack3 = ThoughtfulAutomation.sort(200, 100, 100, 25) // Output: "REJECTED"