Guest User

Untitled

a guest
Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import pprint
  2. pp = pprint.PrettyPrinter(indent=2)
  3. drives = {
  4. 'C:':{},
  5. 'D:':{},
  6. 'E:':{},
  7. 'F:':{},
  8. 'G:':{},
  9. }
  10.  
  11. def parse(line):
  12. global drives
  13. tokens = line.split("\\")
  14. for x in xrange(1,len(tokens)):
  15. if x==1:
  16. if not tokens[1] in drives[tokens[0]]:
  17. drives[tokens[0]][tokens[1]]={}
  18. else:
  19. evalstring = """drives[tokens[0]]["""
  20. for j in xrange(1,x):
  21. evalstring+="tokens[%d]][" % j
  22. exec "if not tokens[x] in " + evalstring[:-1] + " : " + evalstring[:-1] + ".update({tokens[x]:{}})"
  23.  
  24. def getcount(folder, counted=[]):
  25. count=0
  26. for stuff in folder:
  27. if not "." in stuff:
  28. count+=1 + getcount(folder[stuff])
  29. return count
  30.  
  31. def find_max_subs():
  32. maxcount=0
  33. for drive in drives:
  34. for folder in drives[drive]:
  35. subcount = getcount(drives[drive][folder])
  36. if subcount>maxcount:
  37. maxcount=subcount
  38. return maxcount
  39.  
  40. def getfilecount(folder):
  41. count = 0
  42. for stuff in folder:
  43. if "." in stuff:
  44. count += 1
  45. else:
  46. count += getfilecount(folder[stuff])
  47. return count
  48.  
  49. def find_max_files():
  50. maxcount=0
  51. for drive in drives:
  52. for folder in drives[drive]:
  53. subcount = getfilecount(drives[drive][folder])
  54. if subcount>maxcount:
  55. maxcount=subcount
  56. return maxcount
  57.  
  58. line = raw_input()
  59. while len(line)>0:
  60. parse(line)
  61. try:
  62. line = raw_input()
  63. except:
  64. break
  65.  
  66. print find_max_subs(),find_max_files()
Add Comment
Please, Sign In to add comment