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

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)}')