← Reddit Interview Insights

Reddit·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Reddit ML Engineer interview, part of a multi-part coding exercise where they had you keep extending a tennis scoring system. The side-switching follow-up in part 3 was the most interesting design piece and probably where most people trip up.

Questions Asked (1)

Q1

You have a working tennis game implementation. Now modify it so players switch sides between games, following the standard rule where sides swap after odd-numbered games. Side is presentational only and doesn't affect scoring. Where do you track this state and why?

System DesignTechnical Trade-offs
Author's notes

The 'where do you track it' part is what they actually care about.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the side-switching state is purely presentational and should be derived from the game count rather than stored as a separate mutable flag. Propose computing the current side from the total number of completed games (odd games = swapped) and expose it via a read-only method or view model, keeping scoring logic untouched.

Pro tip: Emphasize that deriving side from game count avoids state duplication and synchronization bugs, and mention that if you later need to persist or display side, you can compute it on the fly or cache it with a clear invalidation rule.

1. Identify the source of truth

Recognize that the number of completed games is already tracked for scoring; use that as the single source of truth for side switching.

2. Derive side from game count

Compute the current side as a function of the game count: if game count is odd, sides are swapped; otherwise, they are in the original orientation.

3. Expose side as a read-only property

Add a method or property (e.g., getCurrentSide()) that returns the side for each player without mutating any state.

4. Keep scoring logic separate

Ensure the side-switching logic does not interfere with scoring; it should only affect presentation or display.

5. Consider edge cases and future needs

Handle tiebreaks or other game-counting nuances if applicable, and note that if side needs to be persisted, you can store it but must update it consistently with game count.

Key Points to Mention

  • Single source of truth: game count already exists for scoring, so derive side from it.
  • Avoid mutable state: a separate boolean flag can get out of sync with game count.
  • Presentational only: side switching should not affect scoring logic or game rules.
  • Encapsulation: expose side via a read-only method or view model, not a public field.
  • Testability: derived state is easier to test because it's a pure function of game count.
  • Scalability: if more display variations are needed, the derivation can be extended without changing core logic.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.