Count bitmaps from runs

Write codeHard40 min

Your task

An icon editor stores a black and white bitmap by its run headers instead of its pixels. row_runs[r] lists, left to right, the lengths of the runs of dark pixels in row r, and col_runs[c] does the same top to bottom for column c. Runs in the same line are separated by at least one light pixel, and an empty header means that line has no dark pixels at all. The bitmap has one row per entry of row_runs and one column per entry of col_runs. Return how many bitmaps carry exactly these headers. Return 0 when none does. A bitmap with no rows and no columns has one header set, the empty one, so return 1 there. The bitmap is at most 6 rows by 7 columns and every run length is positive.

Examples

count_matching_bitmaps(row_runs: list[list[int]], col_runs: list[list[int]]) -> int
Example 1
Inputcount_matching_bitmaps([[1], [1]], [[1], [1]])
Output2
Example 2
Inputcount_matching_bitmaps([[3], [1, 1], [3]], [[3], [1, 1], [3]])
Output1
Example 3
Inputcount_matching_bitmaps([[1]], [[1], [1]])
Output0