Count panel shapes

Write codeHard35 min

Your task

A patch panel has n ports, and its wiring sends whatever arrives at port i out through port wiring[i]. Every panel lists each port exactly once, so signals never merge and none is lost. Two panels have the same shape when renumbering the ports of one, one consistent renumbering applied everywhere, reproduces the other panel's wiring exactly. Two panels can share the same shape while agreeing on no single entry, and panels with different port counts never share a shape. Given the panels, return how many distinct shapes are present among them. Return 0 when no panels are given.

Examples

distinct_wiring_shapes(panels: list[list[int]]) -> int
Example 1
Inputdistinct_wiring_shapes([[1, 0, 2], [0, 2, 1]])
Output1
Example 2
Inputdistinct_wiring_shapes([[1, 2, 0], [1, 0, 2]])
Output2
Example 3
Inputdistinct_wiring_shapes([[0, 1, 2], [2, 0, 1]])
Output2