1
0
Fork 0

2018 day 5 part 1

This commit is contained in:
Lucidiot 2018-12-05 07:54:52 +01:00
parent b9c5a076a2
commit 5b48791b96
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
1 changed files with 19 additions and 0 deletions

19
2018/5/alchemy.py Executable file
View File

@ -0,0 +1,19 @@
#!/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())