Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- candidates = set(map(str.strip, open("candidates.txt")))
- submission = list(map(str.strip, open("submission.txt")))
- assert all(element in candidates for element in submission)
- assert submission == sorted(submission)
- def symbols(element):
- for i, c1 in enumerate(element):
- for c2 in element[i + 1:]:
- yield c1 + c2
- symbollist = []
- for element in open("submission.txt"):
- element = element.strip()
- for symbol in symbols(element):
- if symbol not in symbollist:
- symbollist.append(symbol)
- break
- else:
- raise "No available valid symbol for " + element
- symbollist.reverse()
- while symbollist != sorted(symbollist):
- symbollist.pop()
- print(len(symbollist))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement