PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Asana

Model and Solve a Rectangular Jigsaw Puzzle

Last updated: Jul 18, 2026

Quick Overview

Model a rectangular jigsaw puzzle with pieces, rotatable edges, and compatibility rules, then outline a solver that finds a valid arrangement. Address border constraints, candidate indexing, search order, rollback, duplicate-looking pieces, and practical pruning.

  • medium
  • Asana
  • Software Engineering Fundamentals
  • Software Engineer

Model and Solve a Rectangular Jigsaw Puzzle

Company: Asana

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Model and Solve a Rectangular Jigsaw Puzzle Design an object-oriented model for a rectangular jigsaw puzzle and outline an algorithm to solve it. Use concepts such as `Puzzle`, `Piece`, and `Edge`. Each piece has four edges that are flat, inward, or outward and may be rotated. Flat edges belong on the outer border; inward and outward edges may fit when their shapes are compatible. Assume the puzzle dimensions and all pieces are supplied. Return one valid two-dimensional arrangement of oriented pieces, using each piece once. Explain how you identify corner and border candidates, what data structures support matching, and how the solver recovers from a placement that later proves wrong. ### Constraints & Assumptions - The puzzle is rectangular and has at least one valid solution. - A compatibility function decides whether two concrete edges match. - Rotating a piece changes edge positions but not piece identity. - Returning any valid arrangement is sufficient. ### Clarifying Questions to Ask - Can one edge match multiple candidates, or is every match unique? - Are mirror reflections forbidden? - Do edge shapes have stable keys suitable for hashing? - Should the API report all solutions or only the first? ### What a Strong Answer Covers - Cohesive classes with immutable piece identity and explicit orientation - Boundary, corner, and adjacency constraints - Search ordering, candidate indexes, and exact rollback - A final validity check and behavior for malformed input - Honest worst-case complexity and practical pruning ### Follow-up Questions - Which cell should the search fill first? - How would duplicate-looking pieces affect the design? - Can matching be precomputed? - How would you make the solver cancellable?

Quick Answer: Model a rectangular jigsaw puzzle with pieces, rotatable edges, and compatibility rules, then outline a solver that finds a valid arrangement. Address border constraints, candidate indexing, search order, rollback, duplicate-looking pieces, and practical pruning.

Related Interview Questions

  • Design an Extensible Animal-Chess Game Engine - Asana (medium)
  • Design a Testable 2048 Game Engine - Asana (medium)
  • Design and Solve a Rotatable Jigsaw Puzzle - Asana (medium)
  • Design a 2048 Game - Asana (medium)
|Home/Software Engineering Fundamentals/Asana

Model and Solve a Rectangular Jigsaw Puzzle

Asana logo
Asana
Jul 2, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
3
0

Model and Solve a Rectangular Jigsaw Puzzle

Design an object-oriented model for a rectangular jigsaw puzzle and outline an algorithm to solve it. Use concepts such as Puzzle, Piece, and Edge. Each piece has four edges that are flat, inward, or outward and may be rotated. Flat edges belong on the outer border; inward and outward edges may fit when their shapes are compatible.

Assume the puzzle dimensions and all pieces are supplied. Return one valid two-dimensional arrangement of oriented pieces, using each piece once. Explain how you identify corner and border candidates, what data structures support matching, and how the solver recovers from a placement that later proves wrong.

Constraints & Assumptions

  • The puzzle is rectangular and has at least one valid solution.
  • A compatibility function decides whether two concrete edges match.
  • Rotating a piece changes edge positions but not piece identity.
  • Returning any valid arrangement is sufficient.

Clarifying Questions to Ask

  • Can one edge match multiple candidates, or is every match unique?
  • Are mirror reflections forbidden?
  • Do edge shapes have stable keys suitable for hashing?
  • Should the API report all solutions or only the first?

What a Strong Answer Covers

  • Cohesive classes with immutable piece identity and explicit orientation
  • Boundary, corner, and adjacency constraints
  • Search ordering, candidate indexes, and exact rollback
  • A final validity check and behavior for malformed input
  • Honest worst-case complexity and practical pruning

Follow-up Questions

  • Which cell should the search fill first?
  • How would duplicate-looking pieces affect the design?
  • Can matching be precomputed?
  • How would you make the solver cancellable?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Asana•More Software Engineer•Asana Software Engineer•Asana Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.