Widget layout count

Write codeMedium30 min

Your task

A dashboard editor drops widgets onto a fixed canvas. The canvas is panel_rows tall and panel_cols wide, and widget i covers a solid rectangle tile_widths[i] columns across and tile_heights[i] rows down. Widgets never rotate, never overlap, never hang off the canvas, and a saved layout places every widget and leaves no cell bare. Two layouts are the same layout when every cell carries a widget of the same size in both, because the editor stores sizes rather than widget identities and equal sized widgets are interchangeable. Return how many different layouts exist. Return 0 when the widget areas do not add up to the canvas area. A canvas with no cells and no widgets has exactly one layout, the empty one, so return 1 there. There are at most 8 widgets and at most 24 cells.

Examples

count_panel_tilings(panel_rows: int, panel_cols: int, tile_widths: list[int], tile_heights: list[int]) -> int
Example 1
Inputcount_panel_tilings(2, 3, [1, 2], [2, 2])
Output2
Example 2
Inputcount_panel_tilings(2, 4, [1, 1, 2, 2], [2, 2, 1, 1])
Output3
Example 3
Inputcount_panel_tilings(2, 2, [1, 1, 1, 1], [1, 1, 1, 1])
Output1