Last active
June 10, 2019 19:22
-
-
Save JSeam2/445e47cb6a8a9dcf8d42412de36e911b to your computer and use it in GitHub Desktop.
Van Ecks Sequence python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Sample code for van eck's sequence | |
""" | |
output = [0, 0, 1] | |
for i in range(2, 1000): | |
init_len = len(output) | |
last_val = output[i] | |
count = 1 | |
for j in reversed(output[:-1]): | |
if j != last_val: | |
count += 1 | |
continue | |
elif j == last_val: | |
output.append(count) | |
break | |
if len(output) == init_len: | |
output.append(0) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment