def functionA(origin_matrix,N_times):
#apply rule on the origin_matrix to generate another matrix which is the next sate of it.
#apply rule on origin_matrix for N_times
return the_final_matrix
def functionB(origin_matrix):
#determine the period of the the origin_matrix.
return period
iterations = 0;
tmp = origin_matrix;
do
tmp = operation(tmp);
iterations += 1;
while tmp != origin_matrix;
return iterations;
while True:
tmp = operation(tmp)
iterations += 1
if tmp == origin_matrix:
break # Or you could return here.
matrix = origin_matrix
for i in range(N_times):
matrix = operation(matrix)
return matrix