# The Progress Meter

> Report progress at every tenth of the way through.

Canonical URL: <https://datadriven.io/problems/the_progress_meter>

Domain: Python · Difficulty: medium · Seniority: L3

## Problem

Given a non-empty iterable, return the 10%-milestone percentages [10, 20, ..., 100] (exactly 10 elements).

## Worked solution and explanation

### Why this problem exists in real interviews

This tests **milestone tracking with integer arithmetic**, a practical pattern in batch processing systems. It checks whether candidates can compute threshold crossings without floating-point errors.

---

### Break down the requirements

#### Step 1: Compute the item count per 10% milestone

The step size is `total / 10`. Track when the processed count crosses each 10% boundary.

#### Step 2: Iterate and check milestones

For each item processed, check if the current count has reached or passed the next milestone.

#### Step 3: Record and return milestone percentages

Collect each percentage milestone that was crossed during processing.

---

### The solution

**Threshold-based milestone detection**

```python
def progress_milestones(items):
    total = len(items)
    milestones = []
    next_threshold = total // 10
    count = 0
    for item in items:
        count += 1
        if next_threshold > 0 and count % next_threshold == 0:
            pct = (count * 100) // total
            if pct <= 100 and (not milestones or pct > milestones[-1]):
                milestones.append(pct)
    return milestones
```

> **Time and Space Complexity**
>
> **Time:** O(n) with a single pass through the items.
> 
> **Space:** O(1) for the milestones list (at most 10 entries).

> **Interviewers Watch For**
>
> Do you avoid floating-point arithmetic? Using integer division and modulo prevents rounding errors that could cause missed or duplicate milestones.

> **Common Pitfall**
>
> Dividing by 10 when the total is less than 10. If total is 7, then `total // 10` is 0, and checking `count % 0` raises ZeroDivisionError. Guard against this.

---

## Common follow-up questions

- What if milestones should be at 25%, 50%, 75%, 100%? _(Tests parameterizing the milestone intervals.)_
- What if items were processed in parallel? _(Tests atomic counter updates and thread-safe milestone detection.)_
- What if you needed real-time ETA estimates alongside progress? _(Tests tracking elapsed time per milestone and extrapolating.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/the_progress_meter)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.