A TypeScript solution for Thoughtful's robotic automation factory that dispatches packages to the correct stack based on their dimensions and mass.
This application implements a sorting function for a robotic arm that categorizes packages into three stacks:
- STANDARD: Packages that are neither bulky nor heavy
- SPECIAL: Packages that are either bulky OR heavy
- REJECTED: Packages that are both bulky AND heavy
- Bulky: Volume ≥ 1,000,000 cm³ OR any dimension ≥ 150 cm
- Heavy: Mass ≥ 20 kg
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverageExpected Output: All tests should pass, demonstrating correct sorting logic and edge case handling.
- Node.js v22
- npm >= 10.0.0
Note: This project includes a
.nvmrcfile. If you use nvm, runnvm useto switch to the correct version.
src/
├── sort.ts # Core sorting logic
└── sort.test.ts # Test suite
npm test- Run all testsnpm run test:ui- Run tests with interactive UInpm run test:coverage- Generate detailed coverage report
npm run build- Compile TypeScript to JavaScript
npm run lint- Check for linting errorsnpm run lint:fix- Automatically fix linting errorsnpm run format- Format all files with Prettiernpm run format:check- Check if files need formattingnpm run type-check- Validate TypeScript types
- TypeScript
- Node.js v22
- Vitest
- ESLint & Prettier