Design a jigsaw puzzle (OOD)
Company: Asana
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
## Object-Oriented Design: Jigsaw Puzzle
Design an object-oriented model for a **jigsaw puzzle game**.
### Requirements
- The puzzle consists of a set of **pieces** that can be assembled into a final **board** (e.g., an `R x C` grid).
- Each piece has **4 sides** (top/right/bottom/left) that must match adjacent pieces when placed.
- Pieces can be **rotated** (0°, 90°, 180°, 270°).
- The system should support:
- Initializing a puzzle from a collection of pieces.
- Placing/removing a piece on the board.
- Validating whether a placement is legal (in-bounds, cell empty, and sides match neighbors).
- Checking whether the puzzle is solved.
### Clarifications (state assumptions if needed)
- You may assume a rectangular puzzle where each piece occupies one cell in a grid.
- You may represent side “matching” using IDs/keys (e.g., `tab#42` matches `blank#42`) or a comparable abstraction.
### Deliverables
- Propose core classes, key fields, and methods.
- Explain how rotation affects side matching.
- Discuss extensibility (e.g., different board shapes, irregular pieces, multiplayer, UI separation).
Quick Answer: This question evaluates object-oriented design skills, including class and relationship modeling, state and behavior encapsulation, validation logic, and handling piece rotation and side-matching constraints in a puzzle domain.