File: categorize-box-according-to-criteria/solution.py

Date: 2026-06-06

Time: 15:32

Purpose

This file implements LeetCode 2525 — Categorize Box According to Criteria. It classifies a box into one of four categories based on its physical dimensions and mass. It's a standalone solution module following the repo's convention of one problem per directory.

Key Components

boxCategory(length, width, height, mass) -> str — The sole public function. Takes four integers describing a box and returns one of "Both ", "Bulky ", "Heavy ", or "Neither " (all with a trailing space, matching LeetCode's expected output format).

Two intermediate booleans drive the classification:

Patterns

Dependencies

Imports: None — pure function with no external dependencies.

Imported by: The categorize-box-according-to-criteria/test_solution.py file. The massive "Imported By" list in the prompt is an artifact of the repo's test harness — those other test files don't actually import *this* solution; they follow the same import pattern for their own respective solutions.

Flow

1. Evaluate bulky — short-circuits on the first dimension >= 10,000; if none qualify, falls through to the volume comparison.

2. Evaluate heavy — single comparison.

3. Enter the if-chain. The ordering matters: Both is checked first (requires both flags true), then Bulky-only, then Heavy-only, then the default Neither.

The function is a pure mapping from (int, int, int, int) -> str with no side effects.

Invariants

Error Handling

None. The function trusts its inputs are non-negative integers per the problem constraints. No validation, no exceptions. If called with negative dimensions or non-integer types, behavior is undefined but Python's comparison operators will still return *something*.