That python solution solves the same two special cases where cycles occur the the sub-cycles are also linear (that's what the remainder stuff is for... same as mine y=mx+c to get to the start of the cycle and then same linear for the remainder the bit within the cycle.
That works fine when the cycle is a simple "step" like this:
where the bit between the cycles in linear as well but it fails when the bit between cycles is not linear.
For example:
Code:
initial state: #..#.#..##......###...###
105
4140
...##
..#..
.#...
.#.##
.##..
.####
#.#.#
###..
0
My code fails on that, and so does the Python code. But it does cycle (starting at t=45 to t=49). The graph for that input looks like below. Both my code and the python code work if 't' is evenly divisible by the cycle length (t2 - t1), but otherwise my code and the python code both fail even though there the pattern does cycle (the passwords in between the cycle length, the sub cycles, are not linear). I suspect that if that's the official answer they only want it to work in very limited situations (where the cycle and sub-cycle are both linear)