Blame | Last modification | View Log | RSS feed
if __name__ == '__main__':
arrays = [
[0,0,0,0,0],[0,0,0,0,1],[0,0,0,1,0],[0,0,0,1,1],
[0,0,1,0,0],[0,0,1,0,1],[0,0,1,1,0],[0,0,1,1,1],
[0,1,0,0,0],[0,1,0,0,1],[0,1,0,1,0],[0,1,0,1,1],
[0,1,1,0,0],[0,1,1,0,1],[0,1,1,1,0],[0,1,1,1,1],
[1,0,0,0,0],[1,0,0,0,1],[1,0,0,1,0],[1,0,0,1,1],
[1,0,1,0,0],[1,0,1,0,1],[1,0,1,1,0],[1,0,1,1,1],
[1,1,0,0,0],[1,1,0,0,1],[1,1,0,1,0],[1,1,0,1,1],
[1,1,1,0,0],[1,1,1,0,1],[1,1,1,1,0],[1,1,1,1,1]]
# Iterate through each possible initialization vector
for array in arrays:
# Calculate the resulting array up to 64 places
for i in range(200):
array.append((array[i] + array[i+1]) % 2)
# Find equal consecutive arrays
for period in range(5,100):
array1 = array[0:period]
array2 = array[period:2*period]
# If match, print out array and period
if array1 == array2:
print array[0:5], '=', array1, "; Period =", period
break