I'm new to Python, and have spent a while without programming so would very much appreciate your help.
I have to look for all n-length cycles in a given data-structure -I'm currently using lists but maybe a dict would do the work-
Each element in the first row maps directly to the element below it and a cycle is formed if repeated use of the mapping leads back to the initial value. Let's say I have:
A=[[2,3,4,5,6,7,8,9,10],
[6,3,6,1,8,8,4,1,9]]
then cycles are (3)
and (4,6,8)
or
A=[[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
[17, 7, 7, 3, 12, 18, 1, 8, 20, 1, 6, 13, 4, 17, 4, 13, 5, 10]]
Where cycles are (3,7,18,5)
, (6,12)
and (13)
I'm really stuck so thanks in advance for your help.