Solutions to Advent of Code 2017 https://adventofcode.com/2017/
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.

12.py 363B

12345678910
  1. from shared import add_connected_components
  2. with open('data/12.txt', 'r') as file:
  3. sets = []
  4. pipes = list(map(lambda l: l.strip().replace(' <-> ', ', ').split(', '), file.readlines()))
  5. for pipe in pipes:
  6. add_connected_components(sets, pipe)
  7. print(f'Part one: {len(next(s for s in sets if "0" in s))}')
  8. print(f'Part two: {len(sets)}')