← Asana Interview Insights

Asana·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Asana asked me to design an object-oriented model for a jigsaw puzzle game in a real language, with working code. It was a deep OOD question that also touched on algorithms and testing strategy, so it kept branching in ways I didn't fully anticipate.

Questions Asked (1)

Q1

Design an object-oriented model for a jigsaw puzzle game in a real programming language. Your model should include a Puzzle composed of Pieces with edge types (flat, tab, blank), a Board where pieces can be placed with interlocking validation, and support for operations like picking up a piece, rotating it, placing it, snapping connected groups, and checking if the puzzle is solved. Also discuss your class hierarchy, edge-matching logic, and how you'd unit test piece compatibility.

System DesignAlgorithms & Data StructuresData Modeling
Author's notes

I started with the Piece class and worked outward, which felt natural but I spent too long on edge representation before touching the Board at all.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and choosing a language (e.g., Python or Java) to make the design concrete. Then outline the core classes (Puzzle, Piece, Board, Edge) and their relationships, focusing on edge-matching logic and group snapping. Finally, discuss unit testing strategies for piece compatibility and overall puzzle solving.

Pro tip: Mention that you'd represent edges as enums with matching rules, and use a union-find data structure to efficiently manage connected groups during snapping. This shows you think about both correctness and performance.

1. Clarify Requirements and Choose Language

Ask about puzzle size, rotation support, and whether pieces can be placed anywhere or only adjacent to existing pieces. Pick a language you're comfortable with to make the design concrete.

2. Define Core Classes and Relationships

Identify main entities: Puzzle (aggregate of Pieces), Piece (has four Edges), Edge (type: flat, tab, blank), Board (grid of placed pieces), and Player/GameController for operations. Describe how they relate (e.g., Puzzle contains Pieces, Board contains placed Pieces).

3. Design Edge-Matching and Placement Logic

Explain how edges match: a tab matches a blank of the same shape, flat edges only match board boundaries. Describe validation when placing a piece: check all adjacent placed pieces for compatibility.

4. Implement Group Snapping and Solved Check

Use a union-find or graph structure to track connected groups of pieces. When a piece is placed and matches neighbors, merge groups. Puzzle is solved when all pieces form one group and fill the board.

5. Outline Unit Testing Strategy

Write tests for edge compatibility (e.g., tab matches blank, flat doesn't match tab), placement validation (valid/invalid positions), group snapping (merging groups), and solved state (complete vs incomplete puzzles).

Key Points to Mention

  • Edge representation: enum EdgeType { FLAT, TAB, BLANK } with matching rules (TAB matches BLANK, FLAT only matches boundary).
  • Piece class with four edges (top, right, bottom, left) and rotation method that rotates edges.
  • Board as a 2D grid with methods to place, remove, and validate piece placement based on adjacent edges.
  • Group snapping using union-find or graph traversal to merge connected components when pieces are placed.
  • Puzzle solved condition: all pieces placed and all adjacent edges match, forming a single connected component.
  • Unit tests using a testing framework (e.g., JUnit, pytest) with cases for edge matching, rotation, placement, and solved state.

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