Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- workflows, ratings = open("input").read().split('\n\n')
- workflows = {name: rules[:-1].split(',') for name, rules in (line.split('{') for line in workflows.splitlines())}
- ratings= [x[1:-1].split(",") for x in ratings.splitlines()]
- accepted = 0
- for rating in ratings:
- name = 'in'
- for _ in rating:
- exec(_)
- while name not in 'AR':
- for rule in workflows[name][:-1]:
- if eval(rule.split(':')[0]):
- name = rule.split(':')[1]
- break
- else:
- name = workflows[name][-1]
- accepted += x+m+a+s if name == 'A' else 0
- print(accepted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement