Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open('input10.txt') as r:
- l = r.read().split("\n")
- cl = {'(':')','[':']','{':'}','<':'>'}
- def checkrow(i):
- chunks = []
- for j in i:
- if j in cl:
- chunks.append(j)
- else:
- if j != cl[chunks.pop()]:
- return -1
- points = 0
- for i in chunks[::-1]:
- points = points*5+' ([{<'.index(i)
- return points
- scores = list(filter(lambda a: a != -1,[checkrow(i) for i in l]))
- print(sorted(scores)[len(scores)//2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement