Skip to content

arthurrcarrara/fde-solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package Sorting System - FDE Solution

Overview

This repository contains a Python implementation of a package sorting system for Thoughtful's robotic automation factory. The system categorizes packages into different stacks based on their dimensions and mass.

Problem Description

The robotic arm needs to dispatch packages to the correct stack according to their volume and mass:

Classification Rules

  • Bulky Package: Volume ≥ 1,000,000 cm³ OR any dimension ≥ 150 cm
  • Heavy Package: Mass ≥ 20 kg

Stack Categories

  • STANDARD: Packages that are neither bulky nor heavy
  • SPECIAL: Packages that are either heavy OR bulky (but not both)
  • REJECTED: Packages that are both heavy AND bulky

Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)

Installation

  1. Clone or download this repository
  2. Navigate to the project directory
  3. Install development dependencies (optional, for linting and testing):
pip install -r requirements.txt

Basic Usage

Run the package sorting system with command-line arguments:

python solution.py --width <width> --height <height> --length <length> --mass <mass>

Example:

python solution.py --width 100 --height 100 --length 100 --mass 10

Output: SPECIAL

More Examples

# Standard package (small and light) python solution.py --width 50 --height 50 --length 50 --mass 10 # Output: STANDARD # Heavy package (not bulky) python solution.py --width 50 --height 50 --length 50 --mass 25 # Output: SPECIAL # Bulky package by dimension (not heavy) python solution.py --width 200 --height 10 --length 10 --mass 5 # Output: SPECIAL # Rejected package (both bulky and heavy) python solution.py --width 200 --height 100 --length 50 --mass 30 # Output: REJECTED

Development

Running Tests

Execute the comprehensive test suite:

python -m unittest test_solution.py -v

Code Quality Tools

If you installed the development dependencies, you can use the following tools:

Format code:

python -m black solution.py test_solution.py

Type checking:

python -m mypy solution.py

Linting:

python -m flake8 solution.py test_solution.py python -m pylint solution.py test_solution.py

Run tests with coverage:

python -m coverage run -m unittest test_solution.py python -m coverage report -m

Using Makefile (if available)

For convenience, you can use the provided Makefile:

make test # Run tests make lint # Run all linting tools make format # Format code make run-example # Run the README example make all # Format, lint, and test

Project Structure

fde-solution/ ├── solution.py # Main implementation ├── test_solution.py # Comprehensive test suite ├── requirements.txt # Development dependencies ├── pyproject.toml # Tool configurations ├── Makefile # Development shortcuts └── README.md # This file 

Implementation Details

The solution follows Clean Code principles with:

  • Modular Design: Logic split into focused functions
  • Type Hints: Full type annotations for better code clarity
  • Comprehensive Documentation: Detailed docstrings for all functions
  • Input Validation: Proper error handling for invalid inputs
  • Extensive Testing: 100% test coverage with edge cases
  • Code Quality: Formatted with Black, linted with Flake8 and Pylint

Key Functions

  • sort(): Main function that categorizes packages
  • is_bulky(): Determines if a package is bulky
  • is_heavy(): Determines if a package is heavy
  • determine_stack_category(): Maps characteristics to stack categories

Testing

The test suite includes:

  • Unit tests for all individual functions
  • Integration tests for the complete system
  • Edge case testing (zero dimensions, boundary values)
  • Error condition testing (negative inputs)
  • Command-line argument parsing tests
  • Realistic package scenarios

Notes for Reviewers

  • The implementation uses ternary operators as specified in the requirements
  • All dimensions are in centimeters, mass in kilograms
  • The solution handles both integer and float inputs
  • Comprehensive error handling with meaningful error messages
  • Code follows PEP 8 style guidelines
  • Type hints provide clear interface contracts

Quick Verification

To quickly verify the solution works correctly, run these commands:

# Test the main example python solution.py --width 100 --height 100 --length 100 --mass 10 # Run all tests python -m unittest test_solution.py -v # Test edge cases python solution.py --width 149 --height 10 --length 10 --mass 19.9 # Should output: STANDARD python solution.py --width 150 --height 10 --length 10 --mass 20 # Should output: REJECTED

About

Robot solution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors