Here’s the problem:

with open('filefixitlarge.txt', 'r') as f: numCases = int(f.readline()) for i in range(numCases): a = f.readline().split() n = int(a[0]) m = int(a[1]) # n is number of paths that exist # m is number of new paths existingDirs = {} for j in range(n): b = f.readline().replace('\n', "") existingDirs[b] = True counter = 0 for k in range(m): c = f.readline().replace('\n', "") subpaths = c.split('/') del subpaths[0] lsub = len(subpaths) for kk in range(lsub): filematch = '/' + '/'.join(subpaths[:kk+1]) if not filematch in existingDirs: existingDirs[filematch] = True counter += 1 print "Case #%d: %d" % (i+1, counter)

{ 0 comments }