如何检测无限序列中的重复数字?我尝试过Floyd&;Brent检测算法,但一无所获。。。 我有一个生成从0到9(包括0到9)的数字的生成器,我必须识别其中的一个句点。
示例测试用例:
import itertools
# of course this is a fake one just to offer an example
def source():
return itertools.cycle((1, 0, 1, 4, 8, 2, 1, 3, 3, 1))
>>> gen = source()
>>> period(gen)
(1, 0, 1, 4, 8, 2, 1, 3, 3, 1)
目前没有回答
相关问题 更多 >
编程相关推荐