Skip to content

BitzForge/thoughtful-ai-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package Sorting System - Thoughtful Robotics Challenge

Overview

This solution implements a package sorting system for Thoughtful's robotic automation factory. The system categorizes packages into different stacks based on their dimensions and mass, enabling efficient automated handling.

Problem Statement

The system sorts packages using the following criteria:

  • Bulky: A package is bulky if:

    • Its volume (Width × Height × Length) ≥ 1,000,000 cm³, OR
    • Any single dimension ≥ 150 cm
  • Heavy: A package is heavy if:

    • Its mass ≥ 20 kg

Sorting Categories

  1. STANDARD: Packages that are neither bulky nor heavy (can be handled normally)
  2. SPECIAL: Packages that are either bulky OR heavy (require special handling)
  3. REJECTED: Packages that are BOTH bulky AND heavy (cannot be processed)

Solution Implementation

Core Function

sort(width, height, length, mass)

Parameters:

  • width: Width in centimeters (float)
  • height: Height in centimeters (float)
  • length: Length in centimeters (float)
  • mass: Mass in kilograms (float)

Returns:

  • String: "STANDARD", "SPECIAL", or "REJECTED"

Files Structure

├── package_sorter.py       # Main implementation with the sort() function
├── test_package_sorter.py  # Comprehensive test suite
└── README.md              # This documentation file

How to Run

Running the Main Program

python package_sorter.py

This will run a demonstration with various example packages, showing how they are categorized.

Running the Test Suite

python test_package_sorter.py

This executes the comprehensive test suite covering:

  • Standard packages
  • Bulky packages (by dimension and volume)
  • Heavy packages
  • Rejected packages (both bulky and heavy)
  • Edge cases and boundary conditions
  • Real-world scenarios

Quick Test in Python REPL

from package_sorter import sort

# Example usage
result = sort(100, 100, 100, 10)  # Returns "SPECIAL" (bulky by volume)
result = sort(50, 50, 50, 25)     # Returns "SPECIAL" (heavy)
result = sort(150, 150, 150, 25)  # Returns "REJECTED" (both bulky and heavy)
result = sort(50, 50, 50, 10)     # Returns "STANDARD" (neither bulky nor heavy)

Test Coverage

The test suite includes 50+ test cases covering:

Unit Tests

  • Standard packages: Various sizes under all thresholds
  • Bulky packages: Testing each dimension threshold and volume threshold
  • Heavy packages: Testing mass threshold
  • Rejected packages: Testing combinations of bulky and heavy
  • Edge cases: Boundary values (149.99 vs 150, 19.99 vs 20, etc.)
  • Floating point handling: Decimal values
  • Zero and small values: Edge case handling
  • Large values: Extreme dimensions and masses

Integration Tests

  • E-commerce scenarios: Typical online shopping packages
  • Shipping scenarios: Various real-world shipping containers

Algorithm Complexity

  • Time Complexity: O(1) - Constant time operations
  • Space Complexity: O(1) - No additional space required

Design Decisions

  1. Clear Boolean Logic: The solution uses straightforward boolean flags (is_bulky and is_heavy) for clarity and maintainability.

  2. Explicit Threshold Checks: Each dimension is checked individually against the 150cm threshold, making the logic transparent.

  3. Comprehensive Testing: Extensive test coverage ensures reliability across all edge cases and real-world scenarios.

  4. Documentation: Clear docstrings and comments explain the logic and requirements.

Example Output

Running python package_sorter.py produces:

Package Sorting System - Demonstration
============================================================
✓ Small standard package
  Dimensions: 100x100x100 cm, Mass: 10 kg
  Result: SPECIAL (Expected: STANDARD)

✓ Bulky due to width >= 150
  Dimensions: 150x50x50 cm, Mass: 10 kg
  Result: SPECIAL (Expected: SPECIAL)

✓ Heavy package (20kg)
  Dimensions: 100x100x100 cm, Mass: 20 kg
  Result: REJECTED (Expected: SPECIAL)

[... more examples ...]

Requirements

  • Python 3.6 or higher
  • No external dependencies required (uses only Python standard library)

Quick Start (Online)

You can run this solution directly in your browser:

  1. Copy the contents of package_sorter.py
  2. Visit Repl.it or any online Python IDE
  3. Paste the code and run

Author

Solution developed for Thoughtful's Robotic Automation Factory Challenge

License

This solution is provided as-is for the coding challenge evaluation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages