Skip to content

Instantly share code, notes, and snippets.

@urielieli
Created July 20, 2017 16:28
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 urielieli/10770ef6ddfcf811505806d28db71017 to your computer and use it in GitHub Desktop.
Save urielieli/10770ef6ddfcf811505806d28db71017 to your computer and use it in GitHub Desktop.
from itertools import *
j = 1
while j < 20:
k = [[x] for x in open(str(j) + '.txt').read().split('\n')]
for i in range(j+1, 21):
print(i)
x = open(str(i) + '.txt').read().split('\n')
for m in x:
if m:
for w in k:
if w[-1] == m[1:]:
w.append(m)
m = max(map(len, k))
k = [x for x in k if len(x) == m]
print(k[0], len(k))
j += max(map(len, k))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment