Skip to content

Instantly share code, notes, and snippets.

@nineties
Created January 6, 2016 12:15
Show Gist options
  • Save nineties/a00e7a716162ee09f634 to your computer and use it in GitHub Desktop.
Save nineties/a00e7a716162ee09f634 to your computer and use it in GitHub Desktop.
import numpy as np
N = 114514114514
def L(a):
m = np.zeros((64, 64), 'uint32')
m[:64-a, a:] = np.eye(64-a)
return m
I = np.eye(64, dtype='uint32')
T = (I + L(17)).dot(I + L(7).T).dot(I + L(13))
X = I
while N > 0:
if N%2 == 0:
T = T.dot(T)
N //= 2
else:
X = X.dot(T)
N -= 1
y = np.zeros(64, dtype='uint32')
y[63] = 1
y = X.dot(y)%2
print(int("".join(map(str, y)), 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment