My solutions to 2018's advent of code
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

12345678910111213141516171819
  1. import re
  2. from collections import defaultdict
  3. with open('data/03.txt', 'r') as file:
  4. cells = defaultdict(list)
  5. claims = map(lambda l: map(int, re.findall(r'\d+', l)), file.readlines())
  6. ids = set()
  7. for (cid, x, y, width, height) in claims:
  8. ids.add(cid)
  9. for i in range(width):
  10. for j in range(height):
  11. cells[(x + i, y + j)].append(cid)
  12. overlaps = [c for c in cells.values() if len(c) > 1]
  13. print(len(overlaps))
  14. dupes = set(cid for sublist in overlaps for cid in sublist)
  15. print(list(ids - dupes)[0])