Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python2.7
- import collections
- import sys
- import re
- from os import path
- listInput = "list.txt"
- def extractLetters():
- global listInput
- sumOfAll = 0
- if(path.exists(listInput) and path.getsize(listInput) > 0) :
- with open(listInput, "r") as filestream:
- for line in filestream:
- final = ""
- sectorID = re.search("([0-9][0-9][0-9])", line).group(0)
- for c in collections.Counter(line[:-11].translate(None, "-").translate(None, " ").translate(None, "\n")).most_common(8):
- final += c[0]
- mostUsed = re.search("\[(.*)\]", line).group(0).translate(None, "[").translate(None, "]")
- foundChar = 0
- for i in mostUsed:
- for j in final:
- if i == j:
- foundChar += 1
- if foundChar >= 5:
- sumOfAll += int(sectorID)
- print "Final: " + "".join(sorted(final)) + " Most Used: " + "".join(sorted(mostUsed)) + " SectorID: " + sectorID
- print "Total sum: " + str(sumOfAll)
- if __name__ == "__main__":
- extractLetters()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement