Skip to content

Instantly share code, notes, and snippets.

@kurokikaze
Created February 4, 2010 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurokikaze/294565 to your computer and use it in GitHub Desktop.
Save kurokikaze/294565 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from random import randint
import hashlib
def LCSubstr_len(S, T):
m = len(S); n = len(T)
L = [[0] * (n+1) for i in xrange(m+1)]
lcs = 0
for i in xrange(m):
for j in xrange(n):
if S[i] == T[j]:
L[i+1][j+1] = L[i][j] + 1
lcs = max(lcs, L[i+1][j+1])
return lcs
lower = 2**(4*31)
upper = 2**(4*32) - 1
i = 0
j = 0
a = b = hex(randint(lower, upper))[2:-1]
while True:
i = i + 1
if (i > 100000):
j = j + 1
print j
i = 0
h = hashlib.new('md5')
h.update(a)
a = h.hexdigest()
if LCSubstr_len(a, b) > 9:
print 'LCS ' + a + '/' + b + '[' + str(LCSubstr_len(a,b)) + ']'
b = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment