First commit

This commit is contained in:
2026-07-06 06:00:10 +06:00
commit 68696fa4d2
32 changed files with 1085 additions and 0 deletions

34
part1-pricing/README.md Normal file
View File

@ -0,0 +1,34 @@
# Part 1 — Pricing: discount stacking
`pricing/discounts.py` contains `apply_discounts()`, used by our billing
service to price orders that carry one or more percentage discounts. The
current implementation does not follow the billing rules below, and part of
the test suite fails because of it.
## Your task
Update `apply_discounts()` so it implements the billing rules. Run the tests
with:
```bash
pip install -e ".[dev]"
python -m pytest
```
## Billing rules (specification)
1. `base_price` is a non-negative number. A negative `base_price` raises
`ValueError`.
2. `discounts` is a sequence of percentages. Each discount must be within
`0``100` inclusive; any discount outside that range raises `ValueError`.
3. **Stacking is sequential (compounding).** Each discount applies to the
price left over by the previous one — discounts are never summed.
Example: `100.00` with discounts `[10, 20]`:
- after 10%: `90.00`
- after 20% of the remainder: `72.00` ← final price
4. The result is rounded to 2 decimal places.
That is the whole specification. When you are done, note anything worth
mentioning in the repository-level `NOTES.md`.