2018 day 5 part 1
This commit is contained in:
parent
b9c5a076a2
commit
5b48791b96
|
@ -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())
|
Loading…
Reference in New Issue