Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2017 05:28
Show Gist options
  • Save anonymous/cd3dd8e1f09f8950496269dbb47a7e7b to your computer and use it in GitHub Desktop.
Save anonymous/cd3dd8e1f09f8950496269dbb47a7e7b to your computer and use it in GitHub Desktop.
s = list( "abcdefghijklmnop")
goal = list("giadhmkpcnbfjelo")
m = []
for _ in xrange(16):
m.append([0] * 16)
for i in xrange(len(goal)):
m[i][ord(goal[i]) - ord('a')] = 1
end = []
for x in xrange(16):
end.append([x])
def mult(a, b):
c = []
for _ in xrange(len(a)):
c.append([0] * len(b[0]))
for i in xrange(len(c)):
for j in xrange(len(c[i])):
for k in xrange(len(b)):
c[i][j] += a[i][k] * b[k][j]
return c
def pow(b, e):
if e == 1:
return b
if e % 2 == 0:
r = pow(b, e/2)
return mult(r, r)
return mult(b, pow(b, e-1))
m = pow(m, 1000000000)
ans = ""
for x in mult(m, end):
for y in x:
ans += chr(ord('a') + y)
print ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment