# The Face That Breaks the Bank

> Roll enough dice and one number always runs away with it.

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

Domain: Python · Difficulty: medium · Seniority: L4

## Problem

Given a list of rounds (each a list of 6 face values in 1..6) and threshold integer, accumulate per-face totals across all rounds. Return {face: total} for the face with the highest cumulative total, provided that total strictly exceeds threshold; else return {}. Tie-break by smallest face value. The face key in the returned dict is the stringified face value.

## Worked solution and explanation

### Why this problem exists in real interviews

This tests **running accumulation with early termination**, a pattern used in threshold-based monitoring and alerting. It probes whether a candidate can track per-category running totals and short-circuit when a condition is met.

---

### Break down the requirements

#### Step 1: Track cumulative sums per face value

Use a dict to accumulate totals for each of the 6 dice faces.

#### Step 2: Process rounds sequentially

Each round provides 6 values (one per face). Add each value to the corresponding face's running total.

#### Step 3: Return the first face to exceed the threshold

Check after each addition. Return immediately when a face crosses the threshold.

---

### The solution

**Per-face accumulation with threshold check**

```python
def first_to_break(rounds: list, threshold: int) -> tuple:
    totals = {}
    for i in range(1, 7):
        totals[i] = 0
    for round_vals in rounds:
        for face_idx in range(6):
            face = face_idx + 1
            totals[face] += round_vals[face_idx]
            if totals[face] > threshold:
                return (face, totals[face])
    return None
```

> **Time and Space Complexity**
>
> **Time:** O(r) where r is the number of rounds, processing 6 values per round. Early termination can reduce this.
> 
> **Space:** O(1) since there are always exactly 6 face values to track.

> **Interviewers Watch For**
>
> Whether you check the threshold after each individual addition, not just at the end of each round. The first face to exceed could be face 3 in the middle of a round.

> **Common Pitfall**
>
> Using 0-based face numbering. Dice faces are 1 through 6, so map indices correctly.

---

## Common follow-up questions

- What if no face ever exceeds the threshold? _(Tests returning a sentinel value or None.)_
- What if you needed the last face to exceed instead of the first? _(Tests processing all rounds without early termination.)_
- How would you parallelize this across rounds? _(Tests prefix-sum approach for parallel cumulative computation.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/the_face_that_breaks_the_bank)
- [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.