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.

16.py 661B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/python
  2. import re
  3. target = """children: 3
  4. cats: 7
  5. samoyeds: 2
  6. pomeranians: 3
  7. akitas: 0
  8. vizslas: 0
  9. goldfish: 5
  10. trees: 3
  11. cars: 2
  12. perfumes: 1"""
  13. low, high = ['cats', 'trees'], ['goldfish', 'pomeranians']
  14. with open('16.txt', 'r') as file:
  15. for i, line in enumerate(file.readlines()):
  16. for k, v in re.findall('([a-z]+): ([0-9]+)', line):
  17. vs = '|'.join(str(x) for x in (range(int(v)) if k in low else
  18. range(int(v) + 1, 11) if k in high else [v]))
  19. if not re.search('%s: (%s)$' % (k, vs), target, re.M):
  20. break
  21. else:
  22. print('SUE %d' % (i + 1))