Advent of code 2015 solutions https://adventofcode.com/2015/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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)