Advertisement
Guest User

Splurthian Chemistry 103 submission scoring script

a guest
Jul 14th, 2016
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. candidates = set(map(str.strip, open("candidates.txt")))
  2. submission = list(map(str.strip, open("submission.txt")))
  3. assert all(element in candidates for element in submission)
  4. assert submission == sorted(submission)
  5. def symbols(element):
  6.     for i, c1 in enumerate(element):
  7.         for c2 in element[i + 1:]:
  8.             yield c1 + c2
  9. symbollist = []
  10. for element in open("submission.txt"):
  11.     element = element.strip()
  12.     for symbol in symbols(element):
  13.         if symbol not in symbollist:
  14.             symbollist.append(symbol)
  15.             break
  16.     else:
  17.         raise "No available valid symbol for " + element
  18. symbollist.reverse()
  19. while symbollist != sorted(symbollist):
  20.     symbollist.pop()
  21. print(len(symbollist))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement