<分区> 分区>
如果我有一个函数 A,它可以在给定矩阵上应用特定规则来生成另一个矩阵,我称之为原始矩阵的下一个状态,该函数还可以通过以下方式确定矩阵的最终状态给定 N 次(在原点上应用规则,并再次在原点矩阵的下一个状态上应用规则,并应用规则应用规则... N 次)。
假设对于一个给定的矩阵,对其应用规则 5 次,最终矩阵与原始矩阵相同,我们称该矩阵的周期为 5。
我还有另一个函数 B,我怎样才能让函数 B 可以在函数 A 的相同规则下确定给定函数的周期,并返回周期?我只是不知道如何开始制作它.. .提前致谢。
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
