• + 0 comments

    Simple solution: DFS from each intersection (1 .. N) until recursion hits depth 4. When at depth, check if path to current node forms a cycle. Once a cycle is found, add it to a set if it is new (i.e., not isomorphic to discovered cycles). Size of the set is the solution.

    Code is left as an exercise for the reader. (Also my code is terrible.)