Skip to content

Instantly share code, notes, and snippets.

@pi314
Last active January 12, 2016 19:22
Show Gist options
  • Save pi314/908fcf6ec512d3928dba to your computer and use it in GitHub Desktop.
Save pi314/908fcf6ec512d3928dba to your computer and use it in GitHub Desktop.
a = [3, 14, 11, 14, 17, 8, 20, 12, 3, 14]
b = [7, 4, 11, 11, 14]
c = [2, 7, 4, 2, 10, 8, 14, 2, 7, 4, 2, 10, 8, 14, 2, 7]
d = [1, 1, 1, 1, 1, 1, 1]
def foo(seq):
for ret in range(1, len(seq)):
for i, _ in enumerate(seq[ret:]):
if seq[i + ret] != seq[i % ret]:
break
else:
return ret
print(foo(a))
print(foo(b))
print(foo(c))
print(foo(d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment