1
0
Fork 0
adventofcode/2018/5/alchemy.py

20 lines
508 B
Python
Executable File

#!/usr/bin/env python3
from string import ascii_lowercase, ascii_uppercase
import fileinput
import re
def main():
removals = set(map(''.join, zip(ascii_lowercase, ascii_uppercase)))
removals = removals.union({r[::-1] for r in removals})
remove_regex = re.compile('({})'.format('|'.join(removals)))
line = next(fileinput.input()).strip()
count = 1
while count > 0:
line, count = remove_regex.subn('', line)
return len(line)
if __name__ == '__main__':
print(main())