Implement core puzzle/array/grid routines
Problem: Jigsaw Assembly
You are tasked with solving a coding exercise that involves arranging a set of square tiles into a grid. Your solution should demonstrate clean, testable code and include a discussion of its time and space complexity.
Description
You are provided with N square tiles. Each tile has four distinct edges, labeled top, right, bottom, and left, each associated with a string label. Two tiles are considered compatible if their touching edges have identical labels.
A tile can be rotated in increments of 90 degrees (0, 90, 180, or 270 degrees). Each rotation permutes the labels associated with its edges.
Given integers R and C such that R * C == N, your primary goal is to determine whether these N tiles can be arranged into an R x C grid such that all internal adjacent edges between tiles perfectly match.
Deliverables (Optional)
Optionally, if an arrangement is possible, your solution should also return one valid arrangement, specifying the ID of each tile and its final rotation within the grid.
Constraints & Assumptions
Nis small enough to allow for a backtracking approach (e.g.,N <= 12).
AI interview prep
Core dilemma
Balancing the combinatorial explosion of tile placements and rotations with efficient state management and pruning in a backtracking search.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Implement core puzzle/array/grid routines
Problem: Jigsaw Assembly
You are tasked with solving a coding exercise that involves arranging a set of square tiles into a grid. Your solution should demonstrate clean, testable code and include a discussion of its time and space complexity.
Description
You are provided with N square tiles. Each tile has four distinct edges, labeled top, right, bottom, and left, each associated with a string label. Two tiles are considered compatible if their touching edges have identical labels.
A tile can be rotated in increments of 90 degrees (0, 90, 180, or 270 degrees). Each rotation permutes the labels associated with its edges.
Given integers R and C such that R * C == N, your primary goal is to determine whether these N tiles can be arranged into an R x C grid such that all internal adjacent edges between tiles perfectly match.
Deliverables (Optional)
Optionally, if an arrangement is possible, your solution should also return one valid arrangement, specifying the ID of each tile and its final rotation within the grid.
Constraints & Assumptions
Nis small enough to allow for a backtracking approach (e.g.,N <= 12).