Advent of code 2015 solutions https://adventofcode.com/2015/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8.py 733B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/python
  2. import re
  3. with open('8.txt', 'r') as file:
  4. input = file.read()
  5. difference = 0
  6. for line in input.splitlines():
  7. (remaining, count) = re.subn('^"|"$', '', line)
  8. difference += count
  9. (remaining, count) = re.subn('\\\\\\\\', '', remaining)
  10. difference += count
  11. (remaining, count) = re.subn('\\\\"', '', remaining)
  12. difference += count
  13. (remaining, count) = re.subn('\\\\x[a-fA-F0-9]{2}', '', remaining)
  14. difference += count * 3
  15. print(difference)
  16. difference = 0
  17. for line in input.splitlines():
  18. difference += 2
  19. (remaining, count) = re.subn('"', '', line)
  20. difference += count
  21. (remaining, count) = re.subn('\\\\', '', remaining)
  22. difference += count
  23. print(difference)